Hey everybody i´m currently making a ball rolling game.
I´m looking for how to make a platform move from the left to the right.
So when it etc. hits the X position 10, it will move to X - 10 and then repeat.
I currently have a script but the issue is that whenever it hits its max position to the right it makes a very hard transition to moving to the left so the player falls off.
And whenever my player interacts with it its speed gets screwed so it moves slowly.
My Script ```javascript
**#pragma strict
var platform : Transform;
var startTransform : Transform;
var endTransform : Transform;
var platformSpeed : float;
var direction : Vector3;
var destination : Transform;
function Start()
{
SetDestination(startTransform);
}
function FixedUpdate ()
{
platform.GetComponent.().MovePosition(platform.position + direction * platformSpeed * Time.fixedDeltaTime);
You could just subtract or add onto the x value through a Vector3.
public float subtractSpeed; //Move speed
public float maxAmount; //The maxed amount
public bool hitTheEnd; //Has the platform hit the max Value?
public float maxLeftValue;
public float maxRightValue;