#What is this error?
16 messages · Page 1 of 1 (latest)
well
why are you printing "_target" in the init function? You need to do it within your "rotate_to_target" function, because your "_target" is only defined within that scope
you should do it just before you create the var direction
It is defined
then, why do you call "_target" as an argument in the function?
I don't have to call it?
if you don't want to change its value, then no, you can simply call "rotate_to_target(delta)" and then do it exactly as you have it there. Alternatively, which I assume is the problem, is that there is no target defined, right?
If _target is never specified, then I would suggest you to use a different variable name and assign _target to that name (for example "set_to_target" and then "_target = set_to_target", smt like that)
I want it to rotate to the Dummy, hence the _target
- Do you have a reference to the dummy? from the five lines of code you showed, I can only assume that _target has no value assigned to it
- When calling the function, do you have a reference to the dummy as an argument? If not, remove the parameter (you can still access "_target" inside the function if you define _target at the start of the script). This is of course assuming you've always shown snippets from the same script. Else, it'll become more complicated because you'll have to show where you call that function and what you pass as arguments
Here's the dummy
yes, but that won't do anything? "var _target : Dummy" only tells the game "create this variable called _target. This variable can only take as a value something that is of the class Dummy." The game still doesn't have a reference to the dummy that exists in your game world.
Ohhh
So how to create the reference to the dummy?😖
There are several ways. One way is to get the hard path to it and assigning it when declaring the variable. There are two options you have right now. Either you show me your scene tree of the game scene, or you watch the "survivor game" tutorial by gdquest (look in #free-godot-courses ) where they also have something like this (where the gun rotates to enemies)