Little problem with Move With Object. Best way to fix it?

Dayus

New member
Hi,

Well after looking and searching around for days what could possibly go wrong with the "Move With Object" script I finally found the problem.
Just a brief description of the initial problem i had : the player is standing on a spline moving platform and i need the player to swith platfom instantly but the player was drifting alot when on the new platform.

So the problem I found is that once the player enter a moving platform it start the Move With Object ability and set the target but if you change target while the ability is active it won't reset the target platform it keep using the target that initiate the ability.

Now I can fix that easily by modifying the Move with Object script and just making sure it call the setPlatform as soon as the target change. But then I don't like modifying the UCC scripts (because of future update and all)...

So is that a feature to add in a next update?
 

Justin

Administrator
Staff member
Glad you got it working. What change did you make so I can incorporate it into the next version?
 

Dayus

New member
Well here is the change I made, I can't say if it's having an impact on the rest of the controller for sure but from my test it is working.

MoveWithObject.cs

C#:
public Transform Target { get { return m_Target; }
    set {
        // keep a copy of the current target
        Transform oldTarget = m_Target;
        m_Target = value;

        if (m_Target != null && m_Target.GetComponent<Game.KinematicObject>() == null) {
            Debug.Log("Error: The target " + Target.name + " does not have the Kinematic Object component. See the Move With Object documentation for more information.");
            m_Target = null;
        }

        // When the target change while the ability is active (has a target) reset the current platform
        if (oldTarget != null && oldTarget != m_Target)
        {
            m_CharacterLocomotion.SetPlatform(m_Target);
        }
    }
}
 
Top