How to Stop UCC to Allow Different Movement

Nicky_g_

Member
A few weeks ago I switched from Invectors Third person controller to UTPC controller and man they are different. UTPC is a lot more feature rich and I can't not figure out how to disable or have the character stop moving to perform an action I need. I'm working on a golf type game I would like my player to stop moving while they are trying to swing their club like in this video:

( from seconds 5 to 11)

I'm using a Detect Object Ability Base and its going well but I don't know how to stop the player from walking around while they are engaged with the ball. How can I pause UTPC controller?
 
Are you using root motion? Is the movement occuring when your new ability is active?
 
I'm not using root motion, in the video I deactivated Invector and did a simple RotateAround

Code:
float rotateAround = Input.GetAxis("Horizontal");//need to change to Rewired
                characterTransform.RotateAround(golfBallTransform.position, new Vector3(0, rotateAround, 0),
                    (Time.deltaTime * rotateSpeed) / slowRotateSpeed);

I want the player to lock into place and not move about the level just be able to rotate around the ball. This is what I currently have.

This morning I found the Movement types in the documentation but I haven't figured out how to rotate the player around a point (the point being the golf ball).

How can I rotate the player around a point using Movement types or is there a way to deactivate UTPC so I can used a simple rotateAround(I'd prefer not do to this)?
 
You should not be using both Investor and our character controller on the same object. This is going to lead to a lot of problems.

For this situation you should either create a new ability or use the generic ability if you just want to play an animation without any extra functionality. In the docs it has an explanation for how to create a new ability.
 
Sorry what I said was confusing. In the first video I posted I used Invector and what I did was pause Invector's character controller to be able to use Unity's built in RotateAround to be able to rotate the character around the golf ball.

In the second video is my attempt doing RotateAround with UTPC controller. I am not using both controllers in my project.

I've attempted to create my own movement type because at this point animation isn't the most important thing. What I would like to do is lock my player into a set distance away from the ball and then be able to rotate around it. What's confusing me is the custom Movement type script I created won't let me use any input when I return 0,0 in the GetInputVector method. How can I ignore/pause UTPC movement so that I can write a small script to use RotateAround or how can I use a custom MovementType script to rotate around a point?
 
To prevent player directional input, you could use disable "Allow Positional Input" / "Allow Rotational Input" in the ability's "General" settings.
 
Thanks to the help of a close friend I was able to figure it out. Thank you for all the help!

Here is what we came up with just incase if someone else is looking for something similar.

Code:
 public class AddressBall : DetectObjectAbilityBase
   {
      public Transform BallTransform;
      public float DesiredRadius = 1.0f;
      public float rotationspeed = 2;
      
      public override void ApplyPosition()
      {
         base.ApplyPosition();

         if (BallTransform)
         {
            Vector3 ballPlanarPosition = BallTransform.position;
            ballPlanarPosition.y = 0;

            Vector3 playerPlanarPosition = m_Transform.position;
            playerPlanarPosition.y = 0;

            Vector3 toPlayerFromBall = playerPlanarPosition - ballPlanarPosition;

            float horizontalInput = m_CharacterLocomotion.RawInputVector.x;

            toPlayerFromBall = Quaternion.Euler(0, -horizontalInput * rotationspeed, 0) * toPlayerFromBall;
            Vector3 targertOnCircle = ballPlanarPosition + (toPlayerFromBall.normalized * DesiredRadius);

            Vector3 requiredMoveDirection = targertOnCircle - playerPlanarPosition;
            if (requiredMoveDirection.magnitude > 1.0f) requiredMoveDirection = requiredMoveDirection.normalized;
            m_CharacterLocomotion.MoveDirection = requiredMoveDirection;
         }
      }

      public override void ApplyRotation()
      {
         base.ApplyRotation();

         if (BallTransform)
         {
            Vector3 ballPlanarPosition = BallTransform.position;
            ballPlanarPosition.y = 0;

            Vector3 playerPlanarPosition = m_Transform.position;
            playerPlanarPosition.y = 0;

            Vector3 fromPlayerToBall = ballPlanarPosition - playerPlanarPosition;

            Vector3 planarForward = m_Transform.forward;
            planarForward.y = 0;
            m_CharacterLocomotion.Torque = Quaternion.FromToRotation(planarForward, fromPlayerToBall.normalized);
         }
      }
   }
 
Top