"Sitting" Ability

plutonmania

Member
Hello, I try to create new ability for my character.

I started by trying to create the ability "sit" to sit my character on chair.

The animation works well, but the character does not land on the chair, but at the location where I did the action.
I tried to understand the interaction with doors, button or chest a bit. And I based myself a little more on the ability "Drive".

I think I have to define in my script "Sit" a transform to put the player on a position as for the car with the "driverlocation"

Can you help me a little more by telling me what to put in the script.I tried with the M_TRANSFORM, but I have to miss things.
 

Attachments

  • 1.PNG
    1.PNG
    109.4 KB · Views: 5
  • 2.PNG
    2.PNG
    936.3 KB · Views: 5
  • 3.PNG
    3.PNG
    72.6 KB · Views: 5
  • 4.PNG
    4.PNG
    24.8 KB · Views: 7
  • 5.PNG
    5.PNG
    756.6 KB · Views: 6
The ability doesn't know about the Move Towards Location component so within your ability you'll need to override the GetMoveTowardsLocations and provide the component that the character should move to. Take a look at the Interact script for an example.
 
- I have to remove the move Toward Location component, is that what you're telling me? or I have to implement it in the 'sit.cs' script?
- and I have to duplicate the "interact.cs" script to create for put in "sit.cs"?

- or I have to add the 'Interactable' component to the chair?

- or should I remove the 'sit' abitity via 'sit.cs' that I created and rather create a new ability using the already existing 'interact' ability?

so if that's it, I have to add my animations in the animator where 'interact' is already created and put below (press bouton / open chest ... and make sit?

- Do not use the 'drive' model? for player location?

As everything works and it's just that the player does not stick to the chair, I would like to understand how to do it. if you can detail
 
You can use your existing script, but you have to override the GetMoveTowardsLocations ability similar to the Interact script. From here you will be able to provide it with the MoveTowardsLocation component that you added.

Code:
public override MoveTowardsLocation[] GetMoveTowardsLocations()
{
            return m_DetectedObject.GetCachedComponents<MoveTowardsLocation>();
}

Unfortunately due to my work load I am not able to create custom scripts. These concepts are regular C# scripting concepts though so I recommend going through some of the Unity Learn scripting resources in order to get a better understanding of these concepts.
 
Top