Skip to content

Vaticinator/Unity-Item-Interaction

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Item Interaction Component for Unity

Component for basics interactions and very simple game logic.

usage: Open your Unity Project. Paste ItemInteraction.cs file anywhere to your Project window. Now you can use ItemInteraction component in any game object with any kind of collider (isTrigger checkbox has to be selected).

Basic Example

Explaination:

Action Type:

Possible actions are:

  • Animation Triggers (if the Object has an Animator)
  • Hide Object
  • Show Object
  • Play Audio (if the Object has an AudioSource)
  • Stop Audio (if the Object has an AudioSource)
  • Play Particles (if the Object has a ParticleSystem)
  • Stop Particles (if the Object has a ParticleSystem)

Note for Animation Triggers: In Animator under "parameters" tab, you can add parameters in type of trigger with names: enter, exit and key, and then use them in conditions of transitions.

Action Trigger:

You can chose if you want to trigger action when player enter to "collider" or when player exit from "collider" or when player hit key "F" on the keyboard (beeing in range of "collider").

Repeatable:

If selected, action will play any time when player enter/leave "collider". In other case it play action once and then is disabled.

Additional Condition:

With this option you can create some simple logic. For example you can play animation on one object only when you hide different object before... So the door will open when you collect the key.

Delegate Action:

This option is helpful when you want to play selected action on different object.

Additional Notes:

You can add many Interaction Components to one object. For example if you want to hide item and play sound, add two of Interaction Components with different settings.

...Hopefully I will add some video examples soon.

Advanced Example

Tutorials:

Note: You won't find the Character Controller in this repository, but you can use some character controller from Unity Starter Assets or create one by yourself. For videos I played with character controller from Unity HDRP demo scene.

Opening/closing gates

Place a gate into the scene. Create closing and opening animations for this gate. Disable "loop" for animations. For gate game object add "Item Interaction" component and a box collider set as trigger. Setup Animator and that's it. Watch the video:

gate.mp4

Let's go one step further... Adding the gate closing and opening sound. Triggering multiple sounds with a single trigger is a little bit tricky:

gate_sfx.mp4

Animation triggers may have an additional condition. For example, we may need a key.

gate_key.mp4

About

Component for basics interactions and very simple game logic

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages