My script so far is really basic, I wanted to get my character moving before moving onto the more interesting things.
My Code:
var speed : float = 6.0;
var jumpSpeed : float = 8.0;
var gravity : float = 20.0;
private var moveDirection : Vector3 = Vector3.zero;
function Update ()
{
var controller : CharacterController = GetComponent(CharacterController);
if(controller.isGrounded)
{
moveDirection = Vector3(Input.GetAxis( "Horizontal" ), 0, Input.GetAxis( "Vertical" ));
moveDirection = transform.TransformDirection(moveDirection);
moveDirection *= speed;
if(Input.GetButton ( "Jump" ))
{
moveDirection.y = jumpSpeed;
}
}
moveDirection.y -= gravity * Time.deltaTime;
controller.Move(moveDirection * Time.deltaTime);
}
The problem I’m having is that, while this code works on spheres and anything else I attach it too (as long as it has a CharacterController) But it doesn’t seem to work on my imported model?
The model I’ve imported I created in 3DS Max Design and imported it as an .FBX file. It’s in two separate parts, a ‘body’ and a ‘head’ and there both parented under ‘Character Full’.
I’ve been putting the script on Character Full and it does nothing, so tried putting it on just the ‘body’ and it started rolling around and going who knows where, without the head. Tried putting the script on all three parts as well, also didn’t work out.
Any help would be appreciated, sorry if this question has been asked before I wasn’t sure what to search for!