Issue with SetPosition in UCC 2.2

CastleSeven

New member
Hi all - We just updated to UCC 2.2 and I'm having an issue with one of my abilities that was working fine before.

The ability is supposed to trigger when entering a specific area and propel the character forward by a fixed amount. Here's the ability code:

C#:
public class WarpThroughDoor : DetectObjectAbilityBase {

    public override void UpdatePosition()
    {
        base.UpdatePosition();
        Debug.Log("Updating position via ability");
        Vector3 newPos = m_CharacterLocomotion.transform.position + m_CharacterLocomotion.transform.forward * 2.0f;
        m_CharacterLocomotion.SetPosition(newPos);
    }
}


When I enter the trigger everything freezes. Inspection of the Editor log shows repeated "Updating position via ability" messages, which makes me think the trigger is working fine, but we're not updating the position and are instead re-calling the same code because we're still interacting with the trigger space.

Did something fundamental change in 2.2 that needs to be addressed here?

Thanks!
 
You should not be setting the position manually within UpdatePosition. You should instead set the ability motor value to move your character to the desired position. If you want to use SetPosition you should do so outside of the ability system.
 
Thanks for the quick reply Justin - maybe I'm just being dense, but I'm not sure what you mean by "ability motor value". Looking at the Ability API, and the available methods for the DetectObjectAbilityBaseClass, I didn't see anything obvious that stood out to me.

To give some context, the point of this ability is to have the controller's position instantaneously updated to the other side of a wall, so things like "Move" or "Move Towards" won't work as far as I know, as the controller will just collide with the wall. I'm not sure why it used to work and now doesn't, but if SetPosition() is the only way to achieve that I'll move it outside of the ability system like you suggested.
 
As a quick update - I tried the same SetPosition() logic inside ApplyPosition (instead of UpdatePosition) and things are working as the did before.
 
Take a look at the Ride or Drive ability for an example, but you can set the AbilityMotor within UpdatePosition to a delta position instead of using SetPosition. This will ensure the velocities are not going to be reset like they do within SetPosition.
 
Top