- Home /
Question by
xylofiso · Sep 06, 2015 at 12:39 PM ·
rigidbody2dtransform.positionplatformermoving
Making an object move back and forth in a 2D platformer.
I can't figure out how to make an enemy move back and forth on the x-axis.
This is what I am attempting to do in the Update() method of the EnemyStats script:
patrolTimer = Time.deltaTime;
if (patrolTimer >= 0)
{
GetComponent<Rigidbody2D> ().velocity = new Vector2 (speed, GetComponent<Rigidbody2D> ().velocity.x);
patrolTimer = 0;
}
*/
/*
if (patrolTimer >= 4)
{
GetComponent<Rigidbody2D> ().velocity = new Vector2 ((-1 * speed), GetComponent<Rigidbody2D> ().velocity.x);
patrolTimer = 0;
}
*/
Comment