#Vehicle scaled by 2

1 messages · Page 1 of 1 (latest)

magic musk
#

This is the code, if anyone wants it :

class test2_Class: Vehicle 
{
    // user script
    float time;
    float wheelOriginalRadius;
    
    void r_SetScale(IEntity ent, float scale)
    {
        if (!ent)
            return;
        
        ent.SetScale(scale);
        
        for (IEntity child = ent.GetChildren(); child; child = child.GetSibling())
        {
            r_SetScale(child, scale);
        }
    }

    void test2_Class(IEntitySource src, IEntity parent)
    {
        SetEventMask(EntityEvent.FRAME | EntityEvent.INIT);
    }

    override void EOnInit(IEntity owner)
    {
        
        //wheelOriginalRadius = simulation
    }

    override void EOnFrame(IEntity owner, float timeSlice)
    {
        time += timeSlice;
        float scale = /*Math.Max(Math.Sin(time) + 1.0 / 2.0, 0.01)*/2.0;
        VehicleWheeledSimulation simulation = VehicleWheeledSimulation.Cast(FindComponent(VehicleWheeledSimulation));
        for (int i = 0; i < 4; ++i)
        {
            float originalRadius = simulation.WheelGetRadius(i);
            simulation.WheelSetRadiusState(i, originalRadius * scale);
        }
        
        r_SetScale(this, scale);
    }

};
valid fox
#

For characters is changing scale is related to animations?
(Variable character height and girth)

Or would this work for characters as well?