Wrong cells are selected

The code is correct, but I must have messed something in the editor. If i hover over grid tiles, from top to bottom, in the center column, the tiles in the center row, from left to right change instead. I’m pulling my hair here, any idea why this is happening?

Can you post a copy of the code (I know you said its correct and i do believe you its just so i have covered my bases) and also the set up in the hierarchy.
If at all possible a video showing may help to visualize what is occurring here.

Thanks in advance

Absolutely!

Here’s my script:
extends Node3D

@export var max_health: int = 10
var current_health: int:
set(health_in):
current_health = health_in
label_3d.text = str(current_health) + “/” + str(max_health)
var red: Color = Color.RED
var white: Color = Color.WHITE
label_3d.modulate = red.lerp(white, float(current_health) / float(max_health))
if current_health < 1:
get_tree().reload_current_scene()

@onready var label_3d = $Label3D

func _ready() → void:
current_health = max_health

func take_damage():
current_health -= 1

And here’s a short video of the problem.

Cheers!

i had another student earlier, who had something similar where it was offset slightly.

sorry i cant get the videos at the moment.
a good one to do a bit of visual debugging is the enable visible collision shapes in the debug menu, just to see where the raycast is pointing in relation to the mouse pointer.
image

might not the be the same for you, but in the raypicker scene, the raycast3d node had some rotation on it. so i cleared the rotation to 0,0,0 and that remedied the offset.

worth a look.

just what i had earlier

1 Like

Hello your code this irrelevant since it’s not where the raycast is being done (what matters in this context).
But I had the same problem, and after printing the cell coordonates I found that the Y was 3 when it was supposed to be 0. So I manually assign the Y value to 0 and it worked.

This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.

Privacy & Terms