im trying to make a simple game that my character (a ball) bounce around the world
- i add my character movearoud
- i add a bounce physic material to my platform
when i play my game it doesnt work until i add a rigidbody to my character but when i did that my character start jumping like crazy
here is my movearoud script
private var dead = false;
var speed = 6.0;
var rotateSpeed = 3.0;
var bullitPrefab:Transform;
var lifeTime = 1.0;
function LateUpdate()
{
if(dead)
{
if(dead) { transform.position = Vector3( 0,4,0); dead = false; }
}
}
function OnControllerColliderHit(hit : ControllerColliderHit)
{ if(hit.gameObject.tag == “fallout”)
{ dead = true; //substract life here
HealthControl.LIVES -= 1;
}
}
function Update ()
{
var controller : CharacterController = GetComponent(CharacterController);
// Rotate around y - axis
transform.Rotate(0, Input.GetAxis (“Horizontal”) * rotateSpeed, 0);
// Move forward / backward
var forward = transform.TransformDirection(Vector3.forward);
var curSpeed = speed * Input.GetAxis (“Vertical”);
controller.SimpleMove(forward * curSpeed);
if(Input.GetButtonDown(“Jump”))
{
var bullit = Instantiate(bullitPrefab,GameObject.Find(“spawnPoint”).transform.position, Quaternion.identity);
// shoot the bullet at 10m/s
bullit.rigidbody.velocity = transform.forward * 50;
}
}
@script RequireComponent(CharacterController)
To be honest, it's pretty hard to do without rigidbody physics...
– syclamoth