- Home /
3 lane Character controller switching..?
Okay Its been days since i'm after this.The idea is like subway surfers.I have a straight track with 3 lanes (Left= -2.0f,Middle=0.0f,Right=2.0f).A capsule with character controller applied using this code to move forward.
Lerping Using transform.position gave me problem with physics making the character controller pass through the walls and obstacles
Vector3 MovDir=new Vector3(0,1,0);
void Start()
{
Char_Controller = GetComponent<CharacterController>();
}
void Update()
{
Char_Controller.Move(MovDir*Time.deltaTime);
}
Please help.....
Answer by Raiden-Freeman · Feb 26, 2014 at 06:00 AM
You can't use Lerp to move your character! Lerp sets the transform.position of your character, and if it is a non kinematic rigidbody (ergo physics apply), you cannot calculate physics if you simply change the transform.position of the game object. What you want to do is AddForce you can also watch this video
Similar questions: http://answers.unity3d.com/questions/239978/rigidbody-movement-with-addforce.html http://answers.unity3d.com/questions/33466/movement-with-rigidbody.html
Your answer
Follow this Question
Related Questions
I need help with sliding in infinite Runner please someone help 1 Answer
Occasional taking control of Character Controller 1 Answer
How can I have a CharacterController's height make it to where the feet are correctly on the ground? 0 Answers
How to fix a infinity jump? 1 Answer
Problems with character controller 1 Answer