Interacting with nearby things in Godot

preview_player
Показать описание
In this video I talk about how I implemented my system for tracking nearby actionable things and then interacting with them. For this example I use a signpost that triggers some dialogue.

#godot #adventuregame #gamedev #pixelart
Рекомендации по теме
Комментарии
Автор

Interesting. For my game I simply used used a raycast to check where the player is looking at when they press the action button and then check if the colliding object has an action method and if it does, call it.

festerdam
Автор

Lovely solution! I use a pretty similar system, but I hadn't thought of the direction consideration you use, very elegant design

tissueinu
Автор

This video seems to be the sequel of another one, but among the oldest videos I can't find which one lead to this

pwlt
Автор

I can't believe that direction node trick never occurred to me! Nice work.

gamedevmanti
Автор

got an error
expected indented block after 'if' block

RuthlessMetalYT
Автор

I'm trying this method in the scenario of entering a collision area to then interact with it and enter a different scene, but I can't seem to get it to work, or any other method I've looked into. What's the code behind your actionable node?

Coralori
Автор

somehow running a continuous (am I overlapping and and get the shortest distance between actionables in my hitbox) seems, idk. How many actionable are you actually gonna have? Couldn't you rune this check only when the player presses the action button and then the code would run a (am i overlapping....) Only when the player is trying to interact with an object instead of every frame.

or use the area2d signals to know when there is an object and the signal when it leaves the hitbox so theres only one logic check step rather than per frame

ianmclean
Автор

How to stop character movement in dialogue?

keraned
Автор

Suppose you want something to happen to the player on interaction, in addition to the interacted object. For example, when you interact with a flower, then the character plays a pickup animation, and the flower disappears. It seems you're either going to need a lot of type checking in the flower's callback (who interacted with me?) or in the player's callback (what type of thing did I interact with?). How do you minimize coupling and keep this manageable?

ErikSnider
Автор

That's an interesting solution.
For a game I'm working on, I placed all interactable objects in a single YSort. Then, when the player presses the action button, it iterates through all objects in the YSort to check if any objects are in range, and if so, calls interact() within the nearest object (All interactable objects have an interact() function). It seems to work well, but time will tell.

david_artist
Автор

Nice video Nathan! When you say that is continuously searching for for actionable areas (with check_nearest_actionable()) do you mean you are calling it in process()?

The function is not killer or anything, but I tend to avoid process and I personally would have used the Area2D builtin signals, like area_entered. So, when you overlap an actionable area, maybe it could reference that actionable area to the player (with a var). And when it leaves the area (with signal area_exited), if the actionable area var in the player is equal to that action, resets the var.
You could even make that reference var as some array. So when you enter an area where overlaps different actions, they all add their refference to an array (and removes that reference again with area_exited). So when you press the action to trigger an area, it just iterates the array an triggers the one that is closer to the player (or the criterion you would like, like maybe triger the one you are looking, dispite of distance, etc).

(I'm just sharing my own idea on how I would have solved it, is not that one approach is better or anything! (I just dont like using process :D))

learningforever
Автор

If you want multiple actionable things next to each other, you're certainly going to need to tweak the size of the Area2D nodes. But otherwise it's a pretty elegant solution.

KlausWulfenbach
Автор

How did you create the direction node?
I can't manage to get it to change the position of the area2d it has as a child

catgirlcataclysm
Автор

Could you teach me the reason for using a signal like instead of calling a function directly, like nearest_actionable.actioned() ?

ErikSnider
Автор

Why is this such a work around in Godot, Jeeze every other engine iv used is simply (if player in area && key pressed: show sign text) and that's it.

isukwithnames
Автор

what do you use for the icons? they're so cool!

guilhermeflores
Автор

omfg its so much custom nodes to use o.0

GG
Автор

where can i get ready to use scripts, because i really don't understand how to properly use your addon

senyawei
Автор

Hey i have a bug with the dialogue manager:

I wrote an actionable on C# in a 3D project, it does work & it displays the dialogue window, but for some reason, the dialogue skips the "=> END" line, and it repeats the whole dialogue multiple times before closing. Have you encountered with this bug, and how i could fix it?

Levio
Автор

is there an easier way of linking the system to an area signal?

sanyi