- Home /
Offscreen object movement gets wrong
So to make this short, I have three objects with movement script attached to them (script for movement attached below). Because they need to move in certain way I pause each by certain amount of time before they start moving
(object1 delay 1 sec) (object2 delay 3 sec) (object3 delay 2 sec)
and this is because they are next to each other and I need them to move at different times.
Now, when these objects are in camera view they move as intended, but for example if one of them is in camera view and other two aren't, for some amount of time, the order in which they move gets all wrong.
My question is why is this happening, what could cause something like this?
if (startMoving == true) {
if (timer2 >= 1) {
timerBool = false;
}
if (timer2 <= 0f) {
timerBool = true;
}
if (timerBool == true) {
timer2 += Time.deltaTime * (speedUp / 10f);
}
if (timerBool == false) {
timer2 -= Time.deltaTime * (speedDown / 10f);
}
moveX = Mathf.SmoothStep (0, deltaX, timer2);
moveY = Mathf.SmoothStep (0, deltaY, timer2);
v = new Vector2 (startPos.x + moveX, startPos.y + moveY);
rb2D.MovePosition (v);
}
Your answer
Follow this Question
Related Questions
How do i make a mouse look script? 0 Answers
How do I build up speed while wallrunning? 1 Answer
How do I access/use the variable inside a script when the script name is unknown but objectname is? 3 Answers
How to attach a terrain to an object? 1 Answer
Make an object move towards random spot on another objects edge? 1 Answer