- Home /
2d move to point script help
im trying to create a script for 2d gsme and want an enemy to move to point and stop but move back if knocked around now i have a script i got off here(thanks) with some edting but all i need is if the Vector3 Y value of is to hight the enemy stops
var y : float ;
if (transform.position != Vector3(100,-77.48621,79.44936));
if (transform.position <= Vector3.y(-77.48621));
function Start () {
var pointA = transform.position;
var pointB = Vector3(100,-77.48621,79.44936);
while (true) {
yield MoveObject(transform, pointA, pointB, 3.0);
yield MoveObject(transform, pointB, pointB, 3.0);
}
}
function MoveObject (thisTransform : Transform, startPos : Vector3, endPos : Vector3, time : float) {
var i = 0.0; var rate = 1.0/time; while (i < 1.0) { i += Time.deltaTime * rate;
thisTransform.position = Vector3.Lerp(startPos, endPos, i);
yield;
}
} thanks in advance
Your answer
Follow this Question
Related Questions
"sneak mode" (ctrl key) stops my movement. 0 Answers
2D Movement Problems 2 Answers
MoveTowards problem 1 Answer
2d Platform Controller Face Help 1 Answer
objects to move when picked up 0 Answers