- Home /
World and Local Axis out of Alignment
This one's a little hard to explain. I have an object, parent with 1 child, the parent has the scripts(movement, rotation,animation ect) the child has the Renderer.I get weird movement and I think I narrowed it down to the local and global axis being out of alignment. I've tried switching from Space.Self and Space.World. Any ideas why this might be happening?
Here's the snippet where the rotation and movement happens:
if(doRotate == 1){
transform.Rotate(0,Random.Range(-180,180),0,Space.Self);
}
transform.Translate(Vector3.forward * Time.deltaTime * curSpeed);
The object is a Box, btw. The child is animated, while the parent translates (drags on the floor). If that helps..
Answer by Loius · Nov 15, 2012 at 03:59 AM
Your rotate spins the cube to a random facing.
Then you translate it along its new forward.
That sounds pretty weird to me. What's it -supposed- to do?
I want the cubes to move in random directions (theres is also a section in my code that makes them idle randomly). But the basic idea is that they face in a new direction ( a random range from -180 to 180 degrees) and then move forward in that new direction.