I’m very new to gdscript and programming in general so do forgive me if what I coded below looks like complete gibberish, I’m -trying- to work on a card game loop for my game and I just cannot manage to set the render priority properly. I’ve tried a couple alternatives but to no avail it resulted in either nothing or a crash. All and any ideas to make this a bit more refined or at the very least working would be very much appreciated. Much love and thank you all!
extends Node3D
class_name Card
var children := get_children()
var target_y := 0.0
var card_clicked = false
func _ready():
target_y = position.y
func _process(delta):
position.y = lerp(position.y, target_y, 10.0 * delta)
if Input.is_action_just_pressed("leftclick"):
if card_clicked == false:
for child in children:
if child is Sprite3D:
child.render_priority += 33
target_y += 0.3
card_clicked = true
print(card_clicked)
elif card_clicked == true:
for child in children:
if child is Sprite3D:
child.render_priority -= 33
target_y -= 0.3
card_clicked = false
print(card_clicked)
func _on_area_3d_mouse_entered():
for child in children:
if child is Sprite3D:
child.render_priority += 33
if card_clicked == false:
target_y += 0.1
func _on_area_3d_mouse_exited() -> void:
for child in children:
if child is Sprite3D:
child.render_priority -= 33
if card_clicked == false:
target_y -= 0.1
So you don’t want to set the render priority. That doesn’t matter at all. What matters is where your Camera3D is sitting, and how close your Node3D object is to the camera - in comparison to all the other 3D objects in the scene. That determines what you see. So you want to edit it’s position. Most likely by making its position.z higher (if you haven’t changed the rotation of the camera at all).
Thank you very much for the response, but the thing is the nodes itself have multiple sprites within them, so I had to change their render priority beforehand in order to make sure the stats are in between the top and bottom layer etc. I’ve tried to increase the z axis transform however all that changed was that the top layer of the card was now above the other cards top layer, the card art has transparency to it which is probably why they overlap eachother, it seems like I just can’t get the bottom layer to be on top of the art layer no matter how I set it.
Ok, then post a screenshot of your scene tree and your editor so we can see what you’re working with. Because honestly, it sounds like there’s probably a better way to accomplish what you are trying to do.
Yeah there is, my biggest and practically only inspiration for wanting to make this game in the first place was inscryption, making a game board in 2d would have felt too static to me and I feel like a 3D workspace for a similar project would be a lot more entertaining -for me at least- my combat system is also half card battle half regular RPG so I had to improvise with 2.5D quite a bit. I don’t think I have any control nodes currently.
I didn’t know that no! I assumed only render priority handled sprites. But I’d assume that wouldn’t be much of a difference as even if the hovered card was on top of the hierarchy, the card art would probably overlap with eachother and the bottom layer. I’ve tried other options like “process priority” -and basically most of the settings that mentione priority- on the node3d itself but I didn’t get any sort of result from doing that either.
The problem you’re having with the card’s sprite nodes seems strange to me. Have you set Top Level in the Transform of your child nodes to True? Toggling this to True would mean each child node is going off global position rather than local position, which would explain why you’re having issues moving the cards while keeping the art looking right.
If Top Level is set to False then Dragonforge’s earlier suggestion of just changing the card’s Z position should work fine, as all the sprites would be locked to the position of their parent. If this is set to False and you’re still having the same problem, I’m not sure what else could be causing this.
The fact that the answer to it was this simple does make me question myself a bit but eitherway, thank you everyone! You guys are awesome truly. May all of you have a wonderful day, evening or night