0
Planned

Animate float variable how to scale object over time

eagleeyez 3 weeks ago in Game Creator updated by Marti (Lead Developer) yesterday at 4:20 a.m. 6

Animate float variable how to scale object over time


Example I use the reducer potion on a player and instead of it going from big to small immediately it should scale down over time like a few seconds.


Is there something like animate float over time and if not could you make an action for this?

Unity version:
2019.3.0f3
Game Creator version:
1.1.3

This is what Animate float does in Playmaker. You can use it from anything like rotate, scale and position.

Ok, I did it like this and I just have to make a custom action out of it

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class ScaleOverTime : MonoBehaviour
{
    public float targetScale =0.1f;
    public float growFactor = 5f;
    public float waitTime = 0.02f;
    

    // Press S to shrink or grow depending on your targetScale settings
    // in the editor 

    void Start()
    {
        Debug.Log("Started");
    }
    private void Update()
    {
        if (Input.GetKeyDown(KeyCode.S))
        {
            if (targetScale > transform.localScale.x)
                StartCoroutine(GrowMe());
            else if (targetScale < transform.localScale.x)
                StartCoroutine(ShrinkMe());
        }
    }

    IEnumerator GrowMe()
    {
        while (true) 
        {
            while (targetScale > transform.localScale.x)
            {
                transform.localScale += new Vector3(1, 1, 1) * Time.deltaTime * growFactor;
                yield return null;
            }
            yield return new WaitForSeconds(waitTime);
        }
    }
    IEnumerator ShrinkMe()
    {
        while (targetScale < transform.localScale.x)
        {
           transform.localScale -= new Vector3(1, 1, 1) * Time.deltaTime * growFactor;
            yield return null;
        }
        yield return new WaitForSeconds(waitTime);
    }
}

I found a nicer Playmaker action for this called curve float.

Maybe GC can do this already and I am just missing it.

If not, it's easy now to just make my own GC custom actions

Planned

This looks interesting. I like the idea of allowing to interpolate different values. More so now that we have an easing library inside Game Creator.

I'll open a ticket and assess whether this makes sense. Game Creator usually is more on a "higher level of abstraction" than Playmaker, but this should be interesting enough to add.

Thanks!

+1


Ok, on the hub is also this one

Smoothly changes the current numeric variable value to another one over time

https://hub.gamecreator.io/content/item/wklrxyapcCqi4fWTiLj5

EDIT: is useful but not taking in gameobjects..