Hi Everyone,
I am new to AC. I want to control a 3rd person player with Direct control.
When the player is controlled to travelling in one direction and then controlled to travel in the opposite direction, the acceleration how to control its deceleration? The acceleration and deceleration parameter under the Movement settings doesn't seem matter at all.
Can I control the player acceleration in the opposition direction when changing travelling direction by 180 degrees? I also want it to "Turn instantly when under player control".
Thanks for your help.
Comments
The built-in movement system isn't designed to have the exact behaviour you're after, but it is possible to have the speed "reset" if the input direction is reversed. In Char.cs, find the GetNonFacingReductionFactor method, and replace:
else
{
return 1f;
}
with:
else if (IsPlayer && KickStarter.settingsManager.movementMethod == MovementMethod.Direct)
{
Vector2 moveDirectionInput = KickStarter.playerInput.GetMoveKeys ();
Vector3 cameraCorrectedInput = (moveDirectionInput.y * KickStarter.mainCamera.ForwardVector ()) + (moveDirectionInput.x * KickStarter.mainCamera.RightVector ());
float dotProduct = Vector3.Dot (cameraCorrectedInput, transform.forward);
return Mathf.Min (1f, dotProduct * dotProduct);
}
return 1f;
Is that closer to the behaviour you're after? It's certainly possible to make use of another asset or custom motion controller to get the movement you need, but if this change (or some variation of) gets the right result I'll consider adding it as a new option.
AC can work with custom motion controllers, but you must ensure that - as with the Capsule Collider - the Character Controller's bottom is at the root of the object, i.e. a Height value of 2 will result in a Centre Y value of 1. This was the cause of "flying upward" when I tested the above myself.
Currently you must also make sure the "Turn instantly when under player control?" option is unchecked, but I'll look into removing this restriction.
That should allow for you to use the custom controller at all times instead of AC, but custom scripting will be required for a tighter integration - for example, so that control is removed from the player during cutscenes so that you can control him using e.g. the Character: Move to point Action.
The most simple way to do this, in general terms, is to disable your custom control when not in regular gameplay, and set the Player's Motion Control field to Automatic (and vice-versa when in gameplay). In the case of the CharacterMotor script, that would be something like:
if (AC.KickStarter.stateHandler.IsInGameplay ())
{
canControl = true;
AC.KickStarter.player.motionControl = AC.MotionControl.Manual;
}
else
{
canControl = false;
AC.KickStarter.player.motionControl = AC.MotionControl.Automatic;
}
A more complex method would be to have your custom controller move to the destination that AC sets, which can be done by reading the character script's GetTargetPosition() function. However, this is more advanced and requires the custom controller to be equipped with the ability to move to target points without user input.
More on custom motion controllers, along with links to tutorials and script references, can be found in the "Custom motion controllers" chapter of the Manual.
Indeed, the script needs to account for interaction menus if you make use of them - custom movement isn't linked to AC's own movement, so the "Disable movement" field won't have an effect.
AC.Menu is a class name, so you need to get an instance of the class you want in order to access it. The "Menu scripting" chapter of the Manual covers how to do this:
AC.Menu myMenu = AC.PlayerMenus.GetMenuWithName ("Interaction");
However for convenience, the PlayerMenus script has a dedicated method for detecting Interaction menus:
KickStarter.playerMenus.IsInteractionMenuOn ();
As for the Interaction input buttons, what is your Interaction Menu's Source field, are you using a cursor or directly-control the menu, and what are your Interface and Interaction settings in the Settings Manager? There's a lot of choice here that will affect how Interaction menus are triggered. Probably best to just post screenshots of your Settings Manager and Interaction menu's properties.