I’m trying to make a 3D hamster mesh placed inside of a separate ball mesh rotate to face the direction the ball is traveling in. I’m new to coding in javascript.
The ball rolls exactly how I want it to, I just want to put the hamster object in it and make the hamster turn to face in whatever direction the ball is rolling in.
-
Does the hamster need to have a mesh collider with gravity, rigidbody, etc?
-
I tried using LookAt, the follow transform, RotateAround, just about everything I can think of, including solutions given to similar questions on this forum. Spent 8 hours trying to figure it out. Help appreciated
Ball movement script (if this helps):
var up = 15;
var down = -15;
var east = -15;
var west = 15;
var cam : Transform;
var jumpSpeed = 500;
function Jump()
{
rigidbody.AddForce(Vector3.up * jumpSpeed);
}
// Update is called once per frame
function Update () {
if (Input.GetKey("up"))
{
rigidbody.AddForce(cam.transform.forward * up);
}
if (Input.GetKey("down"))
{
rigidbody.AddForce(cam.transform.forward * down);
}
if (Input.GetKey("left"))
{
rigidbody.AddForce(cam.transform.right * east);
}
if (Input.GetKey("right"))
{
rigidbody.AddForce(cam.transform.right * west);
}
if(Input.GetKey("space"))
{
Jump();
}