- Home /
Making Rigidbodies the parent of character controllers is giving me problems.
Hi,
I am currently having two problems with the parenting script in a 2D platforming game.
1) I have a platform(rigidbody) that is floating and rising with the water level, and whenever the character is on the platform I would make the platform the parent of the character, so now the character will rise with the platform without falling of. But then I have another rigidbody falling on the platform causing it to rotate. Once the platform is rotating due to the physics engine, the character starts to rotate with the platform, and once rotated he would stay at an angle for the rest of the level. Any solutions to this problem?
2) I have wrote another script to make another platform to be the parent of the character. But for some reason if Im using both scripts, only one of them will do the parenting and the other script will not. And If I use only one, once I land on the second platform my character is following the position and rotation of the old platform. What is the reason for that and how to solve this issue?
Is there other ways to accomplish what I want to do?
Any help is very much appreciated. Thank you very much.
Answer by Kibsgaard · May 14, 2013 at 04:27 PM
1) In this case I don't parenting is the right solution. If you have not already, you should try out the "Character Motor"-script that comes with the standard assets package "Character Controller". It got code ready for handling platforms and sliding.
2) If the above works, this should not be a problem. In the future, for similar kind of questions, you should write the code from your scripts here.
Thank you so much for the help. I did not know about the character motor. It worked fine as you said but now the character motor is affecting my character script controller. So I can barely jump now but I can move normally. I am using this script http://wiki.unity3d.com/index.php?title=FPSWalkerEnhanced as my controller. Any ideas how to get around this issue. Sorry about not posting my script previously.
Thank you again.
I think the FPSWalkerEnhanced-script is from before Character $$anonymous$$otor was a standard part of Unity. Try using Character $$anonymous$$otor and Platform Input Controller (modify this script to the axis your platform game is using). There is also a FPS Input Controller if that fits your game better.