Unity 6.2
AC 1.84.3
Hi
I'm using a Unity Starter Assets First Person Controller with AC using the AC integration found somewhere on these forums/ downloads page.
Sometimes when I use the Action Character: Move to point with Enforce time limit and teleport to destination enabled, especially if the player is already close to the marker, the Action gets stuck at that point in the cutscene (that Action remains highlighted in green and doesn't move on to the next Action in the Action List) In the editor I'm forced to "stop" the Action List to regain control. Most times it works fine.
Here are some screenshots of my Player inspector and the modified Starter Assets Input_AC script I'm using -
using UnityEngine;
#if ENABLE_INPUT_SYSTEM
using UnityEngine.InputSystem;
#endif
using AC;
namespace StarterAssets
{
public class StarterAssetsInputs_AC : StarterAssetsInputs
{
public bool forceDisableController = false;
public bool acTurnsCamera;
bool wasInGameplay = true;
FirstPersonController playerInput;
AC.Char acCharacter;
bool underACControl;
void Awake()
{
acCharacter = GetComponent<AC.Char>();
acCharacter.motionControl = MotionControl.Manual;
playerInput = GetComponent<FirstPersonController>();
}
void Update()
{
bool isGameplay = KickStarter.stateHandler.IsInGameplay();
if (isGameplay && !wasInGameplay)
{
if (playerInput != null && !forceDisableController)
playerInput.enabled = true;
LookInput(Vector2.zero);
}
if (!isGameplay)
{
if (playerInput != null)
playerInput.enabled = false;
}
wasInGameplay = isGameplay;
underACControl = !isGameplay ||
(!acCharacter.IsPlayer || KickStarter.settingsManager.movementMethod == MovementMethod.PointAndClick) ||
acCharacter.IsMovingAlongPath();
if (underACControl)
{
Vector3 moveDirection = acCharacter.GetTargetPosition() - transform.position;
MoveInput(moveDirection);
if (acTurnsCamera)
{
Vector3 lookDirection = acCharacter.GetTargetRotation() * Vector3.forward;
lookDirection.y = 0f;
LookInput(lookDirection);
}
}
}
private Vector2 GetInputVector(Vector3 worldDirection)
{
worldDirection.y = 0f;
if (worldDirection.sqrMagnitude > 1f) worldDirection.Normalize();
Vector3 cameraForward = KickStarter.CameraMainTransform.forward;
cameraForward.y = 0f;
cameraForward.Normalize();
Vector3 cameraRight = KickStarter.CameraMainTransform.right;
cameraRight.y = 0f;
cameraRight.Normalize();
float forwardAmount = Vector3.Dot(cameraForward, worldDirection.normalized);
float rightAmount = Vector3.Dot(cameraRight, worldDirection.normalized);
return new Vector2(rightAmount, forwardAmount);
}
#if ENABLE_INPUT_SYSTEM
public new void OnMove(InputValue value)
{
if (underACControl) return;
MoveInput(value.Get<Vector2>());
}
public new void OnLook(InputValue value)
{
if (cursorInputForLook)
{
LookInput(value.Get<Vector2>());
}
}
public new void OnJump(InputValue value)
{
if (underACControl) return;
JumpInput(value.isPressed);
}
public new void OnSprint(InputValue value)
{
if (underACControl) { SprintInput(acCharacter.isRunning); return; }
SprintInput(value.isPressed);
}
#endif
}
}
Also my FPS controller - https://pastebin.com/jRzQVduM
It looks like you're new here. If you want to get involved, click one of these buttons!
Comments
Seem to have fixed it (I think) by setting both Minimum distance and Time limit in Move to point to 0.1
Edit: Still gets stuck
Minimum distance and Time limit values of zero will have no effect.
Does this still occur if you uncheck the Copy Marker angle after? option?
I once again seem to have fixed it with a few changes to the Starter Assets script. If it occurs again I'll try unchecking the Copy Marker angle after option.
Btw for future reference - do you mean values of zero for min distance and time limit have no effect as in they will have no effect for fixing my particular issue, or 0 basically disables their functionality? I'm guessing it's the former but just want to make sure.
Script with the fixes -
The latter - a value of zero in those fields will disable their functionality.
Interesting, I'll keep that in mind, thanks!
@armaan Would you mind giving this script a test? It's an adaption of your changes with some tweaks:
Thanks. This doesnt work for my use case - two things that I immediately noticed are that my Custom Action Toggle Player Movement doesn't work (it moves around when I've disabled it) and also the camera spins when I pause the game. The latter was a major issue I had with the original script, which is why I explicitly disable the FPS controller during cutscenes, pause etc.
For reference this is the custom Action