Hey there good evening !
can you may help me with my lazerspear ? i want that i can add it to my player_atack_pos_left and player_atack_pos_right.
But if i do it for some reason if i face the leftside it dont gets velocity like you see in my gif.
I did change the pivot point for the sprite but i would need to do it for the collisionpolygon2D aswell is there a way ?
I did ask in the discord why it did not work they told me maybe because the flip_h of the sprite like you see in my code:
extends Node2D
enum DIRECTION {
left = -1,
right = 1
}
var direction
signal cooldown
onready var timer = $Timer
onready var animation_player = $AnimationPlayer
onready var sprite = $Sprite
export(int) var speed = 100
export(int) var cooldown = 1
export(int) var animationSpeed = 4
func _ready():
animation_player.playback_speed = animationSpeed
cooldown = animation_player.current_animation_length / animationSpeed - 0.1
timer.wait_time = cooldown
_switchScaleValues()
func _initialisation(dir):
if dir == DIRECTION.right:
direction = dir
elif dir == DIRECTION.left:
direction = dir
func _process(delta: float):
position.x += (speed * delta) * direction
func _switchScaleValues():
if direction == DIRECTION.left:
sprite.flip_h = true
else:
sprite.flip_h = false
func _clear():
queue_free()
func _on_Timer_timeout():
emit_signal("cooldown")
and this is the code where i spawn it:
func ability():
var instance = basic_light_atack.instance()
instance._initialisation(direction)
instance.connect("cooldown", self, "reset_ability_cooldown")
if direction == DIRECTION.left:
atack_point_left.add_child(instance)
else:
atack_point_right.add_child(instance)
can you may help me to fix this ?
thanks in advance !~~~~
https://i.imgur.com/kQe4pgS.gif
ps. did not find a way to highlight my code is there a code for it ? :)