Deckard_89
Member
It has a target but not an aim transform. It has both and works correctly with weapons though (at least it does with the pistol I tested).
public override void SetAbilityIKTarget(Transform target, IKGoal ikGoal, float duration)
{
if (m_InteractionSystem == null) {
Debug.LogError("Error: The character must have the Interaction System component in order for the ability to set an IK target.");
return;
}
if (target == null) {
m_InteractionSystem.PauseInteraction(IKGoalToEffector(ikGoal));
}
var interactionObject = target.gameObject.GetCachedComponent<InteractionObject>();
if (interactionObject == null) {
Debug.LogError("Error: The target " + target.name + " must have the FinalIK Interaction Object attached.");
return;
}
m_InteractionSystem.StartInteraction(IKGoalToEffector(ikGoal), interactionObject, false);
}
So you are interacting, and then you try to interact again while the current interact ability is active? The interact ability isn't concurrent so it shouldn't be able to start a second time.I get a weird behavior if I interact again while the animation is playing.
public override void SetAbilityIKTarget(Transform target, IKGoal ikGoal, float duration)
{
if (m_InteractionSystem == null) {
Debug.LogError("Error: The character must have the Interaction System component in order for the ability to set an IK target.");
return;
}
if (target == null) {
m_InteractionSystem.StopInteraction(IKGoalToEffector(ikGoal));
//m_InteractionSystem.PauseInteraction(IKGoalToEffector(ikGoal));
return;
}
var interactionObject = target.gameObject.GetCachedComponent<InteractionObject>();
if (interactionObject == null) {
Debug.LogError("Error: The target " + target.name + " must have the FinalIK Interaction Object attached.");
return;
}
m_InteractionSystem.StartInteraction(IKGoalToEffector(ikGoal), interactionObject, false);
}
void Update() {
if (fullBody == null) return;
UpdateTriggerEventBroadcasting();
Raycasting();
// Finding the triggers in contact and in range
triggersInRange.Clear();
bestRangeIndexes.Clear();
for (int i = 0; i < inContact.Count; i++) {
int bestRangeIndex = -1;
if (inContact[i] != null && inContact[i].gameObject.activeInHierarchy && inContact[i].enabled && ContactIsInRange(i, out bestRangeIndex)) {
triggersInRange.Add(inContact[i]);
bestRangeIndexes.Add(bestRangeIndex);
}
}
// Update LookAt
lookAt.Update();
}
That's a good catch. In the interact ability I'll track the scheduled event for disabling the target and if the interact has been completed before the ik duration then it'll stop the interaction early.The next issue is with the interaction OnAnimatorInteractionComplete Event. The interaction ability can stop while the IK Interaction still hasn't finished. This means the ability can start again even though the IK interaction hasn't completed which result in weird behaviors. Instead of using the animator event to complete the ability you can use the duration of the interaction (as long as the duration is the same for all interaction that's fine, otherwise just add another interaction ability to your character and assign it a different ID).
Interesting. I think contacting RootMotion is a good option to see why that is the case, but maybe there is a way to check if the FinalIK interaction component is active and if it is then LookAt shouldn't be called?This clashes with Final IK bridge the wants Look At to be only updated in Fixed update.
Hi @Deckard_89,
I'm not sure what you mean by interaction triggers. I personally made it work for a button with the following scripts:
"Interactable" "Interaction Object" "Ability Start Location" "Ability IK Target" and "Interaction Target"
You can read the posts I made just above to see how I achieved it, and what problems I had to overcome and why.
I do agree with you that a little demo scene would be nice, because it's not straight forward.
Let me know if you have problems. One that comes up in my head is the rotation speed to set the character in front of the button. You will probably need a state that increases the "Motor Rotation Speed" when the Interact ability is active.