Issues interacting with objects

discofever

New member
First off apologies for my "n00bness" in understanding how UCC works.

So i want to make a simple interaction; character comes and picks up a bottle.
I've added a "Screen Interact" ability in the Abilites and "Move towards".

Character walks to the object but then nothing happens. Using FinalIK.

Here is my setup :

Capture d’écran 2020-03-25 à 13.58.29.pngCapture d’écran 2020-03-25 à 13.59.03.png

On the object
Capture d’écran 2020-03-25 à 13.59.53.png

C#:
using UnityEngine;
using Opsive.UltimateCharacterController.Traits;
// using UnityEngine.Events;

public class PickInteractable : MonoBehaviour, IInteractableTarget
{

    // bool hasInteracted = false;
    // public UnityEvent onInteract;

    public bool CanInteract(GameObject character)
    {
        return true;
    }

    public void Interact(GameObject character)
    {
        Debug.Log("Interact!");
        // hasInteracted = true;
        // onInteract?.Invoke();
    }

}
and

C#:
using Opsive.UltimateCharacterController.Character.Abilities;
using UnityEngine;


[DefaultStartType(AbilityStartType.ButtonDown)]
[DefaultInputName("Action")]
[DefaultAbilityIndex(9)]
[DefaultAllowPositionalInput(false)]
[DefaultAllowRotationalInput(false)]
[AllowMultipleAbilityTypes]

public class ScreenInteract : Interact
{

    public override bool CanStartAbility()
    {
        if (DetectUsingRaycast())
        {
    
            return base.CanStartAbility();
        }

        return false;
    }

    protected override void AbilityStarted()
    {
        Debug.Log("ScreenInteract Started");
        base.AbilityStarted();
    }

    protected override void AbilityStopped(bool force)
    {
        Debug.Log("ScreenInteract Stopped");
        base.AbilityStopped(force);
    }

    private bool DetectUsingRaycast()
    {

        if (m_LookSource == null)
        {
            return false;
        }

        if (Physics.Raycast(m_LookSource.Transform.position, m_LookSource.Transform.forward, out m_RaycastResult, m_CastDistance, m_DetectLayers, QueryTriggerInteraction.Collide))
        {
            Debug.DrawRay(m_LookSource.Transform.position, m_LookSource.Transform.forward, Color.green);
            var hitObject = m_RaycastResult.collider.gameObject;
            if (ValidateObject(hitObject, false))
            {
                m_DetectedObject = hitObject;
                return true;
            }
        }

        return false;
    }


}
 

Justin

Administrator
Staff member
FinalIK adds another layer of complication so I would first get it working without using FinalIK.

Because you have an Animation State Index of -1 that means that you aren't using an animation? When you're just starting to create the ability you should use a placeholder animation instead of using FinalIK because FinalIK adds another layer of complication.

Beyond that, does the interact ability start?
 

discofever

New member
I've finally figured out 'by accident'; comparing my controller to Nolan - I needed to create a 'state' for MoveTowards with MotorRotationSpeed of 500; so basically it was starting but so 'slow' that i couldn't notice.

Now my issue is that when the interaction is starting - right hand moving to IK Target if I move the mouse it f* up the interaction.

So i 'guess' I need to user another property so that i disable mouse AND let LookAtIK point at my object ?

How to achieve this ?
 

Justin

Administrator
Staff member
Glad you're making progress.

Now my issue is that when the interaction is starting - right hand moving to IK Target if I move the mouse it f* up the interaction.
Can you set the weight for final ik so that it has complete control over the arm and not influenced by the look at component? You could add these weight adjustments to your ScreenInteract ability.
 

discofever

New member
Ok will look into it. Otherwise can i just disable input ?

Also, weird that on start Both components related to FinalIK gets disabled ... any idea ?


Capture d’écran 2020-03-25 à 17.38.32.png
 
Top