#I get this specific error

78 messages · Page 1 of 1 (latest)

winged onyx
#
extends Sprite2D
var speed = 200

func _process(_float) -> void:
    $".".rotation = get_local_mouse_position()
    
    if Input.is_action_pressed("right"):
        $".".position.x  += speed * get_process_delta_time()
    if Input.is_action_pressed("left"):
        $".".position.x  -= speed * get_process_delta_time()
    if Input.is_action_pressed("up"):
        $".".position.y  -= speed * get_process_delta_time()
    if Input.is_action_pressed("down"):
        $".".position.y  += speed * get_process_delta_time()

$".".rotation = get_local_mouse_position() this line gives the error

#

I don't know why

#

Please help 😭

zinc quest
#

Are you trying to rotate the parent node?

#

Try get_local_mouse_position.angle()

winged onyx
#

Alright let me try

winged onyx
#

Just the sprite

#

I fixed it by typing this

#

$".".rotation += 1 * get_process_delta_time()

#

But now, it rotates so wonky, it rotates around the starting offset that is not on the sprite

zinc quest
#

Try what I said

winged onyx
#

Can godot let you copy and paste errors? Cause it doesn't let me

#

Oh it does

zinc quest
#

Sorry I meant get_local_mouse_position().angle()

winged onyx
#

It works but

#

now I get 2 sprites??

#

What the?

zinc quest
#

Hiw are you adding the sprites

winged onyx
#

If I screenshot, it looks normal

#

What is this bug?????????

#

This is what it looks screenshotted, but trust me this is not how it looks in game

zinc quest
#

...

#

What's it look like in game lol

winged onyx
#

Made on my phone

zinc quest
#

Well it's happening in process so it's updating every frame. Show your whole code

#

Is it only when you move it?

winged onyx
#

No

#

Everytime

zinc quest
#

Something is spinning it it looks like

#

Because your snapshot, there's only 1

#

Your screenshot

winged onyx
#
extends Line2D
var speed = 200

func _ready() -> void:
    $".".rotation = get_local_mouse_position().angle()

func _process(_float) -> void:
    
    if Input.is_action_pressed("right"):
        $".".position.x  += speed * get_process_delta_time()
    if Input.is_action_pressed("left"):
        $".".position.x  -= speed * get_process_delta_time()
    if Input.is_action_pressed("up"):
        $".".position.y  -= speed * get_process_delta_time()
    if Input.is_action_pressed("down"):
        $".".position.y  += speed * get_process_delta_time()
#

Somehow i get 2 sprites when I rotate right so fast

#

like I keep rotating circles around the sprite and on the right side

zinc quest
#

You dont have 2 sprites . Its spinning so fast it looks like 2 sprites

winged onyx
#

But it's not spinning!

#

I'm not even controlling it

zinc quest
#

You are by moving your mouse

#

Thats the code you just did...

winged onyx
#

Yes

#

but I'm not moving my mouse

zinc quest
#

You put the code in ready

#

So it's happening the moment it starts

winged onyx
#

It happenend the same in _process

zinc quest
#

Of course, the runs every frame

#

When do you want it to happen

winged onyx
#

IT LOOKS NORMAL ON GIF

#

WHAT THE HELL

zinc quest
#

Im not sure what your wanting it to do

winged onyx
#

Ok so

#

I got it rotated

#

By my mouse

#

It's just that it shows 2 sprites

zinc quest
#

Its spinning so fast

#

That it shows 2 to your human eyes

winged onyx
#

It's not a +=

#

It's a =

#

Ok it's fixed with a += now

#

$".".rotation += get_local_mouse_position().angle()

#

What the hell but how?

#

Doesn't the rotation gets increased by my mouse position with .angle() ??

#

Like shouldn't it rotate by itself if i'm not doing anything?

zinc quest
#

Because that's adding to the angle,

#

If it's in delta and your × delta

#

In process I mean

winged onyx
#

What does .angle() do on get_local_mouse_position()?

zinc quest
#

Changes the vector2 to a float

winged onyx
#

I think the issue was that for the .rotation property, it required a vector2 return type from a method

ionic holly
#

maybe because the sprite is at the mouse position so it starts going crazy on rotation

loud flower
winged onyx
#

Nice