So I have a game where the player walks back and forth across the screen I need to keep him at a constant force so originally I was moving him using Translate and Time.deltaTime
This allowed him to move across the screen at a constant speed just fine but I then ran into a number of collision issues. he would get stuck in a wall if flung across the screen too fast instead of turning around when he hit it or he would get stuck in other collision.
So I switched to using the physics engine to add force to him and I got him moving at a constant force now but as soon as he hits a ramp he stops. So my question is how can I get him to ignore this incline? I thought putting constant force under and Update function would push him along how I needed but he wont climb up the angle.
Any thoughts? Thanks as always!
Here's snip of the code I'm using...
private var move = (Vector3(1,0,0));
function Update () {
rigidbody.AddForce(move, ForceMode.Impulse);
}
// Hit edge of screen - invert x direction.
function OnCollisionEnter (hit : Collision)
{
var bump = hit.gameObject.tag;
//hit wall turn around
if( bump == "wallX")
{
//rotate physically
transform.RotateAround(transform.position, Vector3.up, 180);
//change direction
move = (Vector3(-1,0,0));
rigidbody.AddForce(move, ForceMode.Impulse);
Debug.Log("hit");
}
more code and all but this is the code that turns him around.
Another acceptable answer would be to have a way to improve my collision issues when using transform.Translate and Time.deltaTime as this way has been the most accurate way for me to move the player the way I want.