MoveTowards + First Person + Jumping

brian

New member
Hey there,
While experimenting, I made a bit of a "click to move" controller out of the MoveTowards script, by rotating the YawOffset of the MoveTowardsLocation script in the direction the character should be walking.
I can tap once or tap-and-hold anywhere on the terrain, and the character will walk towards that point. It works kind of great, except for a few issues.

1) in Third Person Adventure mode, when I try to jump during a MoveTowards, it will not animate the Jump. My character visibly jumps, but doesn't play the animation. The AbilityIndex parameter goes from -1 to -2 to 0, instead of where it should be going from 1 to 2 to 0. Also, AbilityChange parameter isn't changing as it should be during a jump.

2) If I use MoveTowards in First Person Combat mode, I cannot mouselook around freely while MoveTowards is active. What might be preventing this? I want to click somewhere for my character to go, and still be able to look around elsewhere.


I should mention I'm just using the Nolan demo character. Thank you!
 
For a click to move type of movement I would created a new movement type rather than use the ability system. This will be a cleaner implementation overall. I have gotten a few requests for this and hope to be able to implement it soon.

1. I don't remember seeing the AbilityIndex negative before - can you trace what is setting it to a negative value? A good place to start is by logging the ability parameter values from the Animator Monitor.

2. The Combat View Type is likely preventing your character from rotating so the camera doesn't rotate. If you switch the View Type to Free Look you should have better results.
 
Thanks for the tip about the Animator Monitor.
@Justin I found this gem in UltimateCharacterLocomotion.cs, line 1322:

Code:
            if (m_MoveTowardsAbility != null && m_MoveTowardsAbility.IsActive && !concurrentAbilityIndex) {
                abilityIndex *= -1;
            }

commenting this out makes jumping work when using MoveTowards.

Regarding FreeLook, that helps a bit! If I'll try switching the view type instantly to FreeLook when I'm using MoveTowards, and switch back to combat when it gets WASD input.
 
@Justin: If I need to change between FreeLook and Combat at runtime instantly, is there a way to make my character keep the same orientation? It resets my character's facing orientation when I switch from freelook to combat.
It looks to be a result of this line of code in CameraController's SetViewType method:
Code:
                    if (m_ViewType.RotatePriority) {
                        KinematicObjectManager.SetCameraRotation(m_KinematicObjectIndex, m_ViewType.Rotate(0, 0, true));
                        KinematicObjectManager.SetCameraPosition(m_KinematicObjectIndex, m_ViewType.Move(true));
                    }
 
Last edited:
commenting this out makes jumping work when using MoveTowards.
I completely forgot about that line. The comments say that it was for MoveTowards, but I don't remember what problem I was solving with that. I'll look into it some more and if I can't see a reason to have that then I'll remove it.

@Justin: If I need to change between FreeLook and Combat at runtime instantly, is there a way to make my character keep the same orientation? It resets my character's facing orientation when I switch from freelook to combat.
Just so I'm understanding, you rotate the camera with free look and when you switch back to combat the character snaps back to the direction that the character is facing? If you call ViewType.Reset with the previous camera's rotation it should reorient the camera so it is facing in the given rotation direction.
 
Just so I'm understanding, you rotate the camera with free look and when you switch back to combat the character snaps back to the direction that the character is facing? If you call ViewType.Reset with the previous camera's rotation it should reorient the camera so it is facing in the given rotation direction.

Correct. I just tried the following:
Code:
            Quaternion rot = Camera.main.transform.rotation;
            cameraController.SetViewType(typeof(Opsive.UltimateCharacterController.FirstPersonController.Camera.ViewTypes.Combat), immediate);
            ucLocomotion.SetMovementType(typeof(Opsive.UltimateCharacterController.FirstPersonController.Character.MovementTypes.Combat));
            cameraController.ActiveViewType.Reset(rot);

and that does bad things, because it resets the camera up vector to be the new default, so my my camera becomes "tilted" at the moment this happens.

Also, when I switch from freelook to combat, the camera also kind of bounces. I wonder if this is the spring or bounce parameters on freelook vs combat being out of phase, or something else? Is there any way to apply internal state from one viewtype to another when the view type changes?

So to reiterate- the only thing that gets me closest is my previous message where I comment out line 346 of CameraController, where it was previously resetting the KinematicObjectManager.SetCameraRotation and Position upon changing the view type.
 
Hmm.. ok. I will take a closer look at this and let you know what I find out. I'm glad that you have a workaround for now though.
 
For a click to move type of movement I would created a new movement type rather than use the ability system. This will be a cleaner implementation overall. I have gotten a few requests for this and hope to be able to implement it soon.

1. I don't remember seeing the AbilityIndex negative before - can you trace what is setting it to a negative value? A good place to start is by logging the ability parameter values from the Animator Monitor.

2. The Combat View Type is likely preventing your character from rotating so the camera doesn't rotate. If you switch the View Type to Free Look you should have better results.

Would be lovely if you could implement the click to move Justin.
 
Top