Character controller not moving with parent (boat)
Hi,
So I'm doing this project where I've got a boat and I place a character on the boat. The character is set as child of the boat so I expect it to move along with it when it accelerates.
The problem begins there, the character stays in place as the boat moves forward and then it falls off the boat.
I tried placing any other object with a rigid body on the boat a it moves along it, but I've got no luck with any character controller (Neither 1st or 3rd person)
The boat moves by adding force on it's rear part.
Any Help on this?
Thanks
Btw the FPSController character is set as $$anonymous$$inematic as suggested on other forums but I've got no luck.
Answer by golaod · Jun 09, 2021 at 07:55 PM
It's an old topic, but I just had the same issue. I moved my old project to new unity and new render pipeline system and same script, same player and same platform stopped working.
After checking all the topics with rigidbody, OnTriggerStay, position correction and so on, I found out that there is 'auto sync transforms' option which was not enabled in my new project. When I reenabled it, things went back to normal. (Edit -> Project Settings -> Physics (or Physics 2d) -> Auto Sync Transforms
Answer by bubzy · Oct 13, 2015 at 06:38 AM
you could have a state where the player is in the boat, if he doesnt move at all like
if (enteringVehicle) //or however you want to implement this
{
Destroy(Rigidbody);
}
if(leavingVehicle)
{
gameObject.AddComponent("Rigidbody");
}
or
http://docs.unity3d.com/ScriptReference/Rigidbody-isKinematic.html
Actually I want the player to walk on the boat while it moves, so this solution doesn't work. Also the player must remain at all times on the Boat, so he never really leaves the boat.
About the $$anonymous$$inematic it doesn't works on the regular FPS controller. I just made it work on RigidBodyFPSController. Now the problem seems to be how to change the state when I want the player to $$anonymous$$ove and keep it on $$anonymous$$inematic when I want it to stay still on the boat.
I know I have to use m_RigidBody.is$$anonymous$$inematic =true/ false; and I'm working on it Right now, any ideas?
Thanks!