0 votes

I have this Scene called Main
enter image description here

I want HoleFromHell which is a Position2D to rotate along with the Player which is an instanced scene. The Player moves in a fixed roundabout way, so it should be easy for HoleFromHell to rotate along with it (not exactly, I want it to have a slight delay), how can I do this?

(Roughly how the Player moves)

enter image description here

Main.gd

extends Node2D

export var speed = 150
export (PackedScene) var Mob

var velocity = Vector2()

var score

func _ready():
    randomize()

    new_game()

func _process(delta):
    pass

func game_over():
    $ScoreTimer.stop()
    $MobTimer.stop()

func new_game():
    score = 0
    $StartTimer.start()


func _on_MobTimer_timeout():
    var mob = Mob.instance()
    add_child(mob)
    mob.transform = $HoleFromHell.global_transform


func _on_ScoreTimer_timeout():
    score += 1


func _on_StartTimer_timeout():
    $MobTimer.start()
    $ScoreTimer.start()
Godot version 3.4.2
in Engine by (40 points)

1 Answer

0 votes
Best answer

Added

$HoleFromHell.rotation = lerp_angle($HoleFromHell.rotation, PI + $HoleFromHell.global_position.angle_to_point($Player/Ship.global_position), 0.6)

to _process()

You could also do:

$HoleFromHell.look_at($Player/Ship.global_position)

If you don't care about adding a delay

by (40 points)
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.