I’m trying to make a platform that gets pushed when the player attacks it (by adding x force to the platform), including while he’s standing on it. To get the player to stay on the platform when it moves, I made it so that when the player is standing on the platform, it becomes a child of the platform object (which worked before when I tried making moving platforms in a different project). When trying it, the platform would move, but the player would just ignore it and not move with it while standing on it.
After trying to look up the solution, I found out that apparently rigidbodies completely ignore the movement of their parent objects. What should I use to keep the player on the platform? (I’m trying to make it so that the player can still move freely in relation to the platform while he’s standing on it)
There’s a bunch of different ways completely depending on what kind of motion you expect when on the platform:
parenting and disabling the RB, then remaking it
fixed-joint connecting it, then breaking the joint
switching to a whole different on-platform controller
back-doing the math yourself
etc etc etc
I would suggest checking out some basic tutorials for it. It’s nothing that could ever fit in this little tiny box!
Two steps to tutorials and / or example code:
do them perfectly, to the letter (zero typos, including punctuation and capitalization)
stop and understand each step to understand what is going on.
If you go past anything that you don’t understand, then you’re just mimicking what you saw without actually learning, essentially wasting your own time. It’s only two steps. Don’t skip either step.
Imphenzia: How Did I Learn To Make Games:
If you do run into trouble… here is…
How to report your problem productively in the Unity3D forums:
This is the bare minimum of information to report:
what you want
what you tried
what you expected to happen
what actually happened, log output, variable values, and especially any errors you see
links to actual Unity3D documentation you used to cross-check your work (CRITICAL!!!)
The purpose of YOU providing links is to make our job easier, while simultaneously showing us that you actually put effort into the process. If you haven’t put effort into finding the documentation, why should we bother putting effort into replying?
If you only use AddForce to move your player around then they’ll be carried along by the platform when they land on it. And you won’t need to make the player a child of the platform.