Quantcast
Channel: Questions in topic: "addforce"
Viewing all articles
Browse latest Browse all 1264

Obtaining Constant Speed with AddForce

$
0
0
Hi, I've recently managed to get my character moving with AddForce However when the character starts moving the speed is slow and when I stop moving the character slides (obviously as it accelerates and decelerates) I would like to make my starting velocity a multiple of direction.magnitude and the ending velocity zero. Is this possible? Thanks Code : //On Screen Controls direction = new Vector3(joyScript.position.x, 0, joyScript.position.y); if (direction.magnitude > 0.1f) { Vector3 rightMovement = right * ps3speed * Time.deltaTime * joyScript.position.x; Vector3 upMovement = forward * ps3speed * Time.deltaTime * joyScript.position.y; Vector3 heading = Vector3.Normalize(rightMovement + upMovement); transform.forward = heading; //transform.position += rightMovement; //transform.position += upMovement; rigidbody.AddForce(rightMovement * direction.magnitude * speed); rigidbody.AddForce(upMovement * direction.magnitude * speed); rigidbody.AddForce(transform.forward * direction.magnitude * speed); playerModel.animation.Play("runforward"); playerModel.animation["runforward"].speed = direction.magnitude; } else { playerModel.animation.CrossFade("idle"); } I'd eventually like to add the force on the player to the force of the bullet its producing so the player doesn't run into the bullet when it's fired.

Viewing all articles
Browse latest Browse all 1264

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>