Hi. What I'm trying to do is move a character "from code". To accomplish this I created an empty scene, with just a terrain and 2 character: one of them is the "standard" Nolan, the other one is the one I need to move, let's call it Joe. So I attached a script to Joe that just "copy" Nolan. The "copy" is done in the FixedUpdate method, through the DeterministicObjectManager:
To check whether Joe drift or not I added a debug line in LateUpdate() where I print Joe's actual position and expected position (X and Z).
With just this code, as I was expecting, Joe drift.
So to get rid of the drift I added
void LateUpdate()
{
DeterministicObjectManager.SetCharacterPosition(
mJoe.DeterministicObjectIndex,
Nolan.transform.position + mPositionOffset);
DeterministicObjectManager.SetCharacterRotation(
mJoe.DeterministicObjectIndex,
Nolan.transform.rotation);
}
to the LateUpdate method. This way the drift disappear and Joe is positioned exactly where I want.
The problem is that setting the position causes small glitches to Joe's animation...
So the question is: how should I do? Am I on the right way or is there a better alternative to achieve what I am trying to do (I guess using the AnimatorMonitor)?
(couldn't format the second code, because the editor didn't let me)
C#:
void FixedUpdate()
{
DeterministicObjectManager.SetCharacterMovementInput(
mJoe.DeterministicObjectIndex,
mNolanAnimatorMonitor.HorizontalMovement,
mNolanAnimatorMonitor.ForwardMovement);
DeterministicObjectManager.SetCharacterDeltaYawRotation(
mJoe.DeterministicObjectIndex,
mNolan.DeltaYawRotation);
}
With just this code, as I was expecting, Joe drift.
So to get rid of the drift I added
void LateUpdate()
{
DeterministicObjectManager.SetCharacterPosition(
mJoe.DeterministicObjectIndex,
Nolan.transform.position + mPositionOffset);
DeterministicObjectManager.SetCharacterRotation(
mJoe.DeterministicObjectIndex,
Nolan.transform.rotation);
}
to the LateUpdate method. This way the drift disappear and Joe is positioned exactly where I want.
The problem is that setting the position causes small glitches to Joe's animation...
So the question is: how should I do? Am I on the right way or is there a better alternative to achieve what I am trying to do (I guess using the AnimatorMonitor)?
(couldn't format the second code, because the editor didn't let me)