![]() |
Attention | Topic was automatically imported from the old Question2Answer platform. |
![]() |
Asked By | Mi1k |
I am trying to make a sort of top down bullet hell type game. The user controls the player by using the mouse. After pressing enter, the sprite will continue to follow the mouse.
The problem I’m facing is that once it reaches the mouse, the sprite starts flipping its rotation constantly and it bugs me.
extends "res://MOB.gd"
var has_clicked = false
func control(delta):
look_at(get_global_mouse_position())
velocity = Vector2()
if Input.is_action_pressed("ui_accept"):
has_clicked = true
if has_clicked == true:
$AnimatedSprite.play("movement")
velocity = Vector2(speed, 0).rotated(rotation)
This is the code it extends from.
extends KinematicBody2D
signal health_change
signal dead
export (PackedScene) var Bullet
export (int) var speed
export (float) var cooldown
export (int) var health
export (float) var rotation_speed
var velocity = Vector2()
var can_shoot = true
var alive = true
func _ready():
$Timer.wait_time = cooldown
func control(delta):
pass
func _physics_process(delta):
if not alive:
return
control(delta)
move_and_slide(velocity)