So, guys. I just started a project this morning. On all my little fun experiments, I’ve used a presupplied character controller. This time, I made my own, and here’s how I did it: I made a simple movement script, attached it to a box, and then parented it to the main camera. Simple, right? Just in case it’s necessary, here’s the script I wrote:
> public var speed = 5; function Start () { } function Update () { var newPosition : Vector3 = transform.position; if (Input.GetKey (KeyCode.W)){ newPosition.z += speed * Time.deltaTime; } if (Input.GetKey (KeyCode.S)){ newPosition.z -= speed * Time.deltaTime; } if (Input.GetKey (KeyCode.A)){ newPosition.x -= speed * Time.deltaTime; } if (Input.GetKey (KeyCode.D)){ newPosition.x += speed * Time.deltaTime; } transform.position = newPosition; }
I then made boxes and a wall. Their positions and rotations are locked on all axis, and the character’s position is locked on the y axis. The character’s rotations are locked on all axis as well.
So, I made them all rigidbodies to attempt to make it so that that the character would stop when it hit something. It worked, to the extent that the character could not pass through boxes. However, it gained permanent momentum in the opposite direction that it encountered the rigidbody at. When it came to a wall, the character was flung through it and gained tons of permanent momentum.
I’m not sure where to go from here. I did a bit of research, and saw somewhere to check the “Is Kinematic” button. However, all this did was make the character pass straight through the other boxes.
If you want to actually see this happen, go here:
http://xoraterra.blogspot.com/2012/06/welcome-to-blog.html
Thanks for any help, guys!