orxObject_getSpeed returns zero

Hi guys, I'm trying to get the speed of a moving object using orxObject_GetSpeed. It works on my player who has had the speed set with orxObject_SetSpeed.

But now I'm trying to get the speed of a moving platform, which is moved using FX as setup in the ini file. It looks like GetSpeed is always returning a zero vector on this object. Is it possible to get the current speed of such an object that is moved by a speed effect? Probably I've done something wrong but can't find it yet.

Here is the effect on the object in question:

    [HorzElevatorFX]
    SlotList    =HorzElevatorSpeedSlot
    KeepInCache = true
    Loop        = true

    [HorzElevatorSpeedSlot]
    Type        = Speed
    Curve       = sine
    StartTime   = 0
    EndTime     = 11
    Absolute    = true
    StartValue  = (100,0,0)
    EndValue    = (-100, 0, 0)

Comments

  • edited November 2019

    Hi @funemaker,

    I wasn't able to reproduce your issue. I tested by initializing a new project and replacing the [Object] section with:

    [Object]
    Graphic         = @
    Texture         = pixel
    Size            = (50, 50)
    Pivot           = center
    ChildList       = DebugDisplay
    FXList          = HorzElevatorFX
    
    [HorzElevatorFX]
    SlotList        = HorzElevatorSpeedSlot
    Loop            = true
    
    [HorzElevatorSpeedSlot]
    Type            = speed
    Curve           = sine
    StartTime       = 0
    EndTime         = 11
    Absolute        = true
    StartValue      = (100, 0)
    EndValue        = (-100, 0)
    
    [DebugDisplay]
    Graphic         = @
    Text            = @
    Smoothing       = false
    Pivot           = top left
    UseParentSpace  = position
    Position        = (-0.5, 0.5)
    IgnoreFromParent= scale rotation position.rotation
    TrackList       = DebugTrack
    
    [DebugTrack]
    0               = > Object.GetParent ^, > Object.GetSpeed <, Object.SetText ^ "Speed: <"
    Loop            = true
    

    The speed was correctly displayed under the white square. Are you setting a speed value on your object from another source than your FX by any chance? Does your object have a body? If so, is it a dynamic or kinematic one?

  • Thanks. Yes, it has a body with dynamic set to false. I'm not setting the speed anywhere else.

    I'll see if I can make a simple test project that reproduces it. If not, something else must be going wrong in my code somewhere.

  • Hmm, I can't reproduce it in a simple project, so I'll keep looking at my code to see what is going wrong. I'm getting a reference to the elevator object in a collision event (these are platforms that the player can land on)...possibly I'm somehow getting a reference to the wrong object.

  • Yes, found it! It was my mistake....orx is working exactly as expected! Really enjoying using orx.

  • I'm glad you found it and are still enjoying orx.
    As always don't hesitate if you have any questions. :)
Sign In or Register to comment.