public float Amplitude = 0.05f;
public float PlatformSpeed = 0.14f;
public Vector3 PlatformDirection = Vector3.forward;
private Vector3 Pos0;
private Vector3 movement;
//Inside this update function, we transform the position of the platforms using the amplitude and platformspeed and platformdirection.
//The platformdirection is set within the unity editor to be either on the x, y or z. It is a vector3 to use 3D space. All three public
//variables can be set within the unity editor as well.
void FixedUpdate()
{
Pos0 = transform.position;
//Pos0 = transform.position;
transform.position = Pos0+Amplitudetransform.TransformDirection(PlatformDirection)Mathf.Sin(6.28fPlatformSpeedTime.time);
//rigidbody.MovePosition (movement);
}
That is my code for the moving platform. Whenever i start the scene with the moving platform everything is fine and they move as intended. However, when i start from the menu screen and load the level using Application.LoadLevel(), then thats when the problems arise.
Basically the platforms don’t move the same as if i was to just start the game in the scene with the platforms in them. For example if i load the scene as normal then it will move up, however if i start from the menu and load the level then it will move down instead. When i run it from the menu of the game then it seems that the platforms move in the opposite direction.Ideas?
The platforms are rigidbodies, and so is my player.
EDIT: I SOLVED IT MYSELF. IF ANYONE ELSE IS USING THIS AND HAS THE SAME PROBLEM JUST CHANGE THE Time.time to Time.timeSinceLevelLoad. Now everything is good as gold