Hi,
I've sort of rehashed this tutorial:
, to use a 3 button mouse
It worked, until I tried to be able to remove obstacles, see the addObstacle() function.
Any help greatly appreciated!
.
.
.
It's a basic setup
- A 3d world with a base Spatial node named World
- Add 3 GeometryInstance's named Grid, Obstacles and DrawPath
- Add a Spatial (named CamPivot) and a Camera as its child
.
.
.
The Camera script is:
extends Camera
const ray_length = 1000
func _input(event):
if event is InputEventMouseButton and event.pressed: # and event.button_index == 1:
var from = project_ray_origin(event.position)
var to = from + project_ray_normal(event.position) * ray_length
var space_state = get_world().direct_space_state
var result = space_state.intersect_ray(from, to, [], 1)
if result:
var o = get_tree().get_root().get_child(0)
o.clicked(result.position, event.button_index)
.
.
.
The World script is:
https://gist.github.com/little-totoro/fe8127bddb69cb30b391d93e924a7cdb