Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | Kajak |
So i want a projectile(Fireball) to shoot in mouse direction, so i have a function in my Player script that makes a instance of the Fireball per click, and that works perfect,
func Fireball():
var Fireball = load("res://Magic/Fireball/Fireball.tscn")
var fireball = Fireball.instance()
var Level = get_tree().current_scene
Level.add_child(fireball)
fireball.position = get_global_position()
But the script for shooting the Fireball in mousedirection doesnt work, The Projectile does not move
extends Area2D
var speed = 10
var movement = Vector2()
onready var mouse_pos = null
func _ready():
mouse_pos = get_global_mouse_position()
func _physics_prozess(delta):
movement = movement.move_toward(mouse_pos, delta)
movement = movement.normalized() * speed
position = position + movement
I cant figure out what im doing wrong, thank for your anwers!