Skip to content

Is it Unity Interaction System?

Hey everyone,

I'm working on my 2D game using Unity as my game egnine and I got stuck with something that might seem like a stupid question. ๐Ÿ˜…

But I need to know how to make certain objects in a game checkable by the player. Meaning the play can click on the object such as an image and it enlarges and players can flip/rotate, zoom in/out during playtime.

For example, a picture on the wall, once clicked on becomes full screen.

I tried to search for the interaction system in Unity but didn't find much helpful tips. ๐Ÿ˜…

1 points0 comments
Open on Reddit
About this post
Posted
Archived
Score
1 ยท 60% up
Kind
Text
ID
160spjo

Author

29
posts
20
comments
15
media
View profile

2 comments

You'll have to create an interaction component class and interface IInteractable.

In the interface create a method called OnInteraction() and implement this interface on the needed classes.

On the interaction component create a method Interact and have it shoot a raycast when you press a certain button in the direction you're looking, with the TryGetComponent method on the hit variable of the raycast look for an IInteractable interface, if found, execute the OnInteraction() method.

This os as far as i can help from mobile. Look into the documentation of Physics2D.Raycast and TryGetComponent if needed.

Best of luck!

4 points

Keyboard shortcuts

Move and act

jork
Next / previous post or comment
Enteroro
Open the post
f
Open the media viewer
s
Save
h
Hide (the toast has Undo)
Tab
Right after an action: the toast's Undo
x
Collapse the comment
v
Next layout: cards, compact, grid

Go to

/
Search
gthenh
Home
gthena
All
gthens
Subreddits
gthenl
Library
?
This list
Esc
Close a menu or this list

In the viewer

โ†orโ†’
Previous / next file
โ†‘orโ†“
Previous / next post
korj
Previous / next post
Space
Play / pause
m
Mute
z
Zoom
s
Save
o
Open the post (on its own page: back to it)
Esc
Close

Keys do nothing while you type in a box.