- Home /
Question by
youngtraffords96 · Aug 07, 2011 at 03:11 PM ·
move
Move Script Error
Would you guys be able to search through this to why my character will no longer move back or forward? I know it's a mess, but I can't figure out the problem. I can still rotate and shoot, but that is all.
//Moving Around
var speed = 3.0;
var rotateSpeed = 3.0;
//Shooting
var bullitPrefab:Transform;
//Dying
private var dead = false;
//Getting Hit
function OnControllerColliderHit (hit : ControllerColliderHit)
{
if (hit.gameObject.tag == "fallout"){
dead = true;
//subtract life here
HealthControl.LIVES -= 1;
}
if (hit.gameObject.tag == "enemyProjectile"){
gotHit = true;
}
}
function Update () {
var controller : CharacterController = GetComponent(CharacterController);
// Rotate around y - axis
transform.Rotate(0, Input.GetAxis ("Horizontal") * rotateSpeed, 0);
var forward = transform.TransformDirection(Vector3.forward);
var curSpeed = speed * Input.GetAxis ("Vertical");
controller.SimpleMove(forward * curSpeed * Time.deltaTime);
if(Input.GetButtonDown("Jump"))
{
var bullit = Instantiate(bullitPrefab,
GameObject.Find("spawnPointGood").transform.position,
Quaternion.identity);
bullit.rigidbody.AddForce(transform.forward * 2000);
}
if (dead)
{
transform.position = Vector3(0,4,0);
gameObject.Find("Main Camera").transform.position = Vector3(0,4,-10);
dead = false;
}
}
@script RequireComponent(CharacterController)
Comment
If you are not getting any errors then it is properly a collision problem. Try changing the character out and replace it with a cube or sphere.
And another idea, if there is a rigidbody on it, disable the gravity and see what it does.
Your answer
Follow this Question
Related Questions
Make Arms Move Slow 0 Answers
How to make enemy run animation 3 Answers
Move an object through a set of positions 2 Answers
Move from point A to point B, then destroy? ( java S) 2 Answers
How to move particles from script ? 3 Answers