Godot Version
4.3 stable
Question
Hello everyone, I am new to programming and Godot but I understand some of the basics. My goal is for the player (I’m using the included Godot icon) to start spinning continuously as it touches the Goal, which is an Area2D.
The following is what I came up with but is not working:
NOTE: This script is attached to the player.
class_name Player
extends CharacterBody2D
@onready var player: Player = %Player
@onready var goal: Area2D = $"../Goal"
var max_speed := 600.00
func _physics_process(_delta: float) -> void:
var direction := Input.get_vector("move_left", "move_right", "move_up", "move_down")
velocity = direction * max_speed
move_and_slide()
goal.body_entered.connect(func (body: Node) -> void:
if body is not Player:
return
var player := body as Player
player.rotate(.1)
The condition is running inside the _physics_process ( ) function, I don’t understand why the player doesn’t start rotating.
If you decide to reply, I will really appreciate if you could explain in details and perhaps give a simple example writing some GD Script lines, since I’m a visual learner.
Here’s a screenshot of my code:
Btw, the player in the scene tree has no collision shape, I added the collision shape but it’s still not working. Once the player touches the goal (Area2D) it will instantly rotate to a random angle but it won’t rotate continuously which is my goal.