FANDOM


This custom action will call Final IK's Start Interaction function with options for which Interaction System to call it on, what Effector Type (body part), which Interaction Object, and a bool for interrupting:

bool StartInteraction (FullBodyBipedEffector effectorType, InteractionObject interactionObject, bool interrupt)

Here's a tutorial showing how the custom action was created. The video also covers how to use the action in a project:

https://www.youtube.com/watch?v=uTc5y9XA0ak

Here's the Custom Action and how to use it:
FinalIKStartInteraction

Script: ActionFinalIKStartInteraction.cs

using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using RootMotion.FinalIK;
#if UNITY_EDITOR
using UnityEditor;
#endif
 
 namespace AC
 {
 	[System.Serializable]
 	public class ActionFinalIKStartInteraction : Action
 	{        
         public GameObject interactionSystem;
        public bool isPlayer;
        public FullBodyBipedEffector effector;
        public GameObject interactionObject;
        public bool interrupt;
        public int constantID_is, constantID_io;
        public int parameterID_is, parameterID_io = -1;

        public ActionFinalIKStartInteraction()
		{
			this.isDisplayed = true;
			category = ActionCategory.Custom;
			title = "Final IK Start Interaction";
			description = "This calls Final IK StartInteraction function";
		}

        override public void AssignValues(List<ActionParameter> parameters) {
            if (isPlayer) {
                interactionSystem = KickStarter.player.gameObject;
            }
             else {
                interactionSystem = AssignFile(parameters, parameterID_is, constantID_is, interactionSystem);
            }            
            interactionObject = AssignFile(parameters, parameterID_io, constantID_io, interactionObject);            
        }
 
         override public float Run ()
		{
            if (interactionSystem && interactionObject ) {
                InteractionSystem interactionSystemScript = interactionSystem.GetComponent<InteractionSystem>();
                InteractionObject interactionObjectScript = interactionObject.GetComponent<InteractionObject>();
                if (interactionSystemScript && interactionObjectScript) {
                    interactionSystemScript.StartInteraction(effector, interactionObjectScript, interrupt);
                }
            }
             return 0f;
		}
		
		#if UNITY_EDITOR
		override public void ShowGUI (List<ActionParameter> parameters)
		{			
			isPlayer = EditorGUILayout.Toggle("Interaction System on Player:", isPlayer);
            if (isPlayer) {
                interactionSystem = KickStarter.player.gameObject;
                parameterID_is = -1;
            }
             else {
                parameterID_is = Action.ChooseParameterGUI("Interaction System:", parameters, parameterID_is, ParameterType.GameObject);
                if (parameterID_is >= 0) {
                    constantID_is = 0;
                    interactionSystem = null;
                }
                else {
                    interactionSystem = (GameObject)EditorGUILayout.ObjectField("Interaction System:", interactionSystem, typeof(GameObject), true);
                    constantID_is = FieldToID(interactionSystem, constantID_is);
                    interactionSystem = IDToField(interactionSystem, constantID_is, true);
                }                
            }
             effector = (FullBodyBipedEffector)EditorGUILayout.EnumPopup("Full Body Biped Effector:", effector);
            parameterID_io = Action.ChooseParameterGUI("Interaction Object:", parameters, parameterID_io, ParameterType.GameObject);
            if (parameterID_io >= 0) {
                constantID_io = 0;
                interactionObject = null;
            }
             else {
                interactionObject = (GameObject)EditorGUILayout.ObjectField("Interaction Object:", interactionObject, typeof(GameObject), true);
                constantID_io = FieldToID(interactionObject, constantID_io);
                interactionObject = IDToField(interactionObject, constantID_io, true);
            }
             interrupt = EditorGUILayout.Toggle("Interrupt:", interrupt);
            AfterRunningOption ();
		}
		
		public override string SetLabel ()
		{
			string labelAdd = "";
            if (interactionObject) {
                labelAdd = " " + effector + " on" + interactionObject.name;
            }
 			return labelAdd;
 		}
 		#endif
 	}
 }

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.