extends Camera
member variables here, example:
var a=2
var b="textvar"
var to = Vector3(0,0,0)
var from = Vector3(0,0,0)
func fixedprocess(delta):
var ds = PhysicsServer.spacegetdirectstate(getworld().getspace())
if(Input.isactionpressed("leftclick")):
var col = ds.intersectray(from, to)
print(col.keys())
if("collider" in col.keys()):
var obj = col["collider"]
var colpos = col["position"]/2
var blockpos = Vector3(ceil(colpos[0]), ceil(colpos[1]), 0)
obj.setcellitem( int(colpos[0]), int(colpos[1]), 0, -1)
print(obj.getcell_item( int(colpos[0]), int(colpos[1]), 0))
print(col["position"])
func input(event):
if (event.type == InputEvent.MOUSEBUTTON and event.buttonindex == BUTTONLEFT and event.pressed):
from = self.projectrayorigin(event.pos)
to = from + self.projectraynormal(event.pos)*10000
func ready():
# Called every time the node is added to the scene.
# Initialization here
setprocessinput(true)
setfixed_process(true)
pass
I use the above script to grab a block in a gridmap node. You should be able to modify it for any other node though using var obj = col["collider"].
Mainly it projects a ray from the camera and uses that to select a node, but I'm unsure if I used a collision node as the parent, or if you need a physics setup.