hi,
i want to move several blocks up and down. So when the first block is up the second block should be down… The problem is every time i start the game the blocks have a different behavior (frequency)… sometimes if the first block is up the second block is up too. But i want everytime the same behaviour(frequency). What should i do?
Code:
if(up)
this.transform.position.x -= 100 * speed * Time.deltaTime;
if(down)
this.transform.position.x += 100 * speed * Time.deltaTime;
if(transform.position.y > upObject.transform.position.y){
up = true;
down = false;
} else if(transform.position.y < downObject.transform.position.y){
down = true;
up = false;
}
Hello 
have you tried to put that code on the FixedUpdate()?
and try to create a script that controls them all, not a script for each one 
That way, you are going to have your cubes moving by a single script, and all the time.deltaTime are going to be applied to all the cubes.
I think your problem (not sure 100%) could be that your deltaTime is not always the same because your Update() function is not called at constant time step
hope this helps you 
Hi,
One approach you might consider is to make the movement of the second (and other blocks) dependent on the position of the first. That is, rather than test its own position, test the position of the key block.
Regards,
Peter
Hi there,
Here is a code snippet in .js
public var height = 3.2;
//public var left = 3.2;
//public var depth = 3.2;
var speed = 2.0;
var timingOffset = 0.0;
private var originalPosition : Vector3;
function Start (){
originalPosition = transform.position;
}
function Update (){
var offsetHeight = (1 + Mathf.Sin(Time.time * speed + timingOffset)) * height / 2;
//var offsetLeft = (1 + Mathf.Sin(Time.time * speed + timingOffset)) * left / 2;
//var offsetDepth = (1 + Mathf.Sin(Time.time * speed + timingOffset)) * depth / 2;
transform.position = originalPosition + Vector3(0, offsetHeight, 0);
}
Apply this to multiple objects. The offsetHeight variable will alloud you to make them start at different position and time.
Cheers,
Romain.
Thank you guys
i will test all 3 possibilities and choose the best one 