#Trying To Get Projectile To Move Toward Player

1 messages · Page 1 of 1 (latest)

mystic sparrow
#

you can get a vector direction facing from the projectile to the player using direction = (player.position - position).normalize(), then change it's unit speed by doing velocity = velocity.move_toward(direction, turn_speed * delta)? this is assuming you want to move towards the direction to the player

feral thunder
#

doesn't seem to be working

#
velocity = velocity.move_toward(direction, turn_speed * delta```
mild ferry
#

Null instance means your player variable has nothing in it, meaning it was loaded incorrectly
Can you show the code where you instantiate the player variable? Maybe the path is wrong or something

tepid python
#

I don’t if I understood what do you wanna do… do you to make a normal bullet like a bullet that goes from the position where your player was toward?

mystic sparrow
#

I'm assuming he means make a homing bazooka from Worms

feral thunder
#

I'm trying to have a rocket track the player along the x axis, but not the y so if it misses it just fires past it

feral thunder
#

do I have to preload the player?

mild ferry
#

What node is this script on? Can you share the scene tree too

feral thunder
#

it's an area 2D

mild ferry
#

Hmm sorry I'm not sure then, maybe someone else can assist

feral thunder
#

Been fiddling with it for days now and still can't seem to get it to work. I think I might have to give up on this for now

mystic sparrow
#

try finding an example of it working from another game