B
BagarraoEduardo
Guest
Hi all,
I'm migrating a game that I've been developing in Unity to GMS2, and I'm struggling with this part as I don't know how to implement this in GML.
Basically I just wan't to make a object move in one position to another in a certain amount of time throwing balls, just like this.
The code that I used to make this in Unity:
private IEnumerator MoveCoroutine(float desiredPosition, float timeToReachTarget)
{
float timePassed = 0f;
while (timePassed < 1)
{
yield return null;
} }
I'm trying to do something similar in GMS2 but without result, as the object goes away and the x of the object turns NaN. Here's the code:
Create event
Step event
Please help my, I can't see a way to fix this. Thanks in advance!
Best Regards,
Eduardo Bagarrão
I'm migrating a game that I've been developing in Unity to GMS2, and I'm struggling with this part as I don't know how to implement this in GML.
Basically I just wan't to make a object move in one position to another in a certain amount of time throwing balls, just like this.
The code that I used to make this in Unity:
private IEnumerator MoveCoroutine(float desiredPosition, float timeToReachTarget)
{
Vector2 currentPos = transform.position;
Vector2 targetPos = new Vector2(desiredPosition, transform.position.y);float timePassed = 0f;
while (timePassed < 1)
{
timePassed += Time.deltaTime / timeToReachTarget;
transform.position = Vector3.Lerp(currentPos, targetPos, timePassed);yield return null;
}
I'm trying to do something similar in GMS2 but without result, as the object goes away and the x of the object turns NaN. Here's the code:
Create event
Step event
Please help my, I can't see a way to fix this. Thanks in advance!
Best Regards,
Eduardo Bagarrão