Im working on a game for the iphone where you tilt the screen to move a character but i want the character to move forward really fast on its own. Sounds kinda lame but i need help getting the player to move forward on its own. I tried rigidbody.AddForce and something that went like rigidbody.velocity(transform.position * 10) but it didnt work. Any suggestions at all would help
Here two samples, one without and one with physics. If you use the physics one, be sure you have a rigidbody attached and a collider. Be sure the Drag of the rigidbody is 0.
float speed = 2.0f;
//Either this
void Update()
{
transform.position += transform.forward * speed * Time.deltaTime;
//I don't recall if "transform.position += something", if not,
//user "transform.position = transform.position + something"
}
//or that
void FixedUpdate()
{
//this
rigidbody.AddForce(transform.forward * speed, ForceMode.VelocityChange);
//or that for physics, but it's not the best way
rigidbody.velocity = transform.forward * speed;
}
If you don't need physics in your game, I really suggest you the first solution to increase performance on iphone. I used C# but it should be easy to make it in javascript if you use that.
I am a bit of a noob in unity but,
for a constant movement have you considered something like this:
count = count + speed;
transform.position = Vector3(xpos, ypos, zpos+count);