![]() |
Attention | Topic was automatically imported from the old Question2Answer platform. |
![]() |
Asked By | lifeman100 |
I’m trying to create an inventory like in Resident Evil 4 with Control nodes. So I’m trying to implement rotation with the drag and drop functions in Control nodes
I keep a reference to the itemPreview and then do a rotation by 90 degrees everytime a button is pressed:
itemPreview.set_rotation(itemPreview.get_rotation() + deg2rad(90))
Now in the location where I’m dropping the item, I do some intersect tests between the item i’m dragging and all the other item rects. Everything works correctly before I rotate anything. After rotating, it seems to still be using the old rect positions(?) I’m not sure exactly what’s going on. I hope the screenshot I included helps. And here’s the code for testing whether I can drop an item or not:
func can_drop_data(_pos, data):
var canDrop = true
var items = get_children()
for item in items:
if item == data.item:
continue
if item.get_global_rect().intersects(data.itemPreview.get_global_rect()):
canDrop = false
return canDrop
screenshot link if it didn’t work: https://imgur.com/a/nwS3x2m