How to have a moving platform move a characterController

Greetings,
I’m a complete beginner to Unity and coding and everything (as in, before 2 months ago I had never opened Unity) but I have also started a Uni course that was advertised as being for beginners and I feel like I’m drowning.

On to my problem, I am making a first person platformer using CharacterController, I have put in moving platforms using the oscillator script from the Project Boost course but my Player won’t stay on the platform.

I have tried parenting the Player to the platform which didn’t work and I have since read that the CharacterController shouldn’t be made a child of anything as it doesn’t like and can screw with things.

My most recent attempt was by using a Raycast to detect if the Player is on a moving platform by checking the tag of the platform through an if else statement , if the player is on a moving platform then isOnPlatform was true and set the players position to that of the moving platform offset on the Y slightly so the player actually stood on the platform, else isOnPlatform was false.

This gave me my closest success but once on the platform, the player was stuck there and couldn’t get off.

Any help or tips would be greatly appreciated.

Parenting the player to the platform is usually the way to go. What was not working?

My characters are usually a child of another object and I’ve never had issues

Here is a clip from when I was making the player the child.

via GIPHY

So, my code was successfully making the player the child but it wasn’t moving the player at the same rate. I did notice after that the scales are different and I know that can be an issue but even when setting the scales of everything to 1,1,1, I still had the same issue. It was after that that I read on Unity that the CharacterController shouldn’t be made a child and so I stopped looking further into parenting.

Your gif baffled me. I can see it being parented so it should work. I tried this in one of my projects that uses the character controller and it didn’t work either. Some research and I found that there is a setting that is not on by default (I think it’s new). Once I set that, it worked fine. Go to Edit -> Project Settings... -> Physics and find the Auto Sync Transforms option. Make sure it’s checked.

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms