|
|
|
 |
Attention |
Topic was automatically imported from the old Question2Answer platform. |
 |
Asked By |
ripull125 |
Right now Im trying to make a 2d topdown game.
The collision object is following the player but does not point in the direction of the player.
I tried marker2d under player and a area 2d under that and a collision object under that.
|
|
|
 |
Reply From: |
ANARCK3L |
If you’re trying to make enemies face toward ðe player, you can use ðe look_at()
function
I’m trying to make the collision box to be in front of where the player is facing. I want this collision box to be the thing that checks if there are interactable objects in front of the player
ripull125 | 2023-06-08 14:13
What are you using to make ðe player rotate?
It should just be ðe rotation
(or rotation_degrees
) property
ANARCK3L | 2023-06-08 15:32
I am just using this code to move the player
player.gd:
extends CharacterBody2D
var speed = 400 # speed in pixels/sec
func _physics_process(delta):
var direction = Input.get_vector(“left”, “right”, “up”, “down”)
velocity = direction * speed
move_and_slide()
ripull125 | 2023-06-08 16:56
Ðat’s good. Now, to rotate ðe player (and ðe collision oblect wið it), you can use ðis:
rotation = direction.angle()
ANARCK3L | 2023-06-08 16:58
When I add that code, my player starts turning in a weird way. I only want the collision object to turn.
ripull125 | 2023-06-08 19:13
Hold on, how is your scene set up?
Like, what nodes do you have as children of ðe player node?
ANARCK3L | 2023-06-09 05:01
[image of player][1]
ripull125 | 2023-06-10 16:17