Hi, I'm a newbie to game development in general and I'm trying to create a 3D isometric view game. The concept is simple. The user traces a path in maze like environment and the car follows the path (but limited by its max speed). I found a way to get mouse position in 3D but I'm unable to create a proper path and pathfollow using that. I'm caught in that cruel stage where there is no error but nothing works. I'll put my main.gd code and scene tree here.

extends Spatial
onready var camera = $CameraPivot/Camera
onready var cursor= $Cursor
onready var follower = $Mouse_path/Mouse_follow/Cursor2follow
onready var mousepath = $Mouse_path
onready var mousefollow = $Mouse_path/Mouse_follow
# Called when the node enters the scene tree for the first time.
func _ready():
# mousefollow.rotation_mode = PathFollow.ROTATION_Y
mousefollow.loop = false
Input.set_mouse_mode(Input.MOUSE_MODE_HIDDEN)
func _physics_process(delta):
mouse_path()
if Input.is_action_just_released("Click"):
followmouse(delta)
func mouse_path():
var ray_length = 1000
var dropPlane = Plane(Vector3.UP, 2.0)
var mouse_pos = get_viewport().get_mouse_position()
var from = camera.project_ray_origin(mouse_pos)
var to = from + camera.project_ray_normal(mouse_pos) * ray_length
var cursor_pos = dropPlane.intersects_ray(from,to)
if Input.is_action_pressed("Click"):
mousepath.curve.add_point(cursor_pos)
print(mousepath.curve.get_point_count())
cursor.global_transform.origin = cursor_pos
func followmouse(delta):
mousefollow.set_offset(mousefollow.get_offset() + 5*delta)
print(mousefollow.get_offset())
pass
Does anyone here know about implementing path based on mouse input? Or is there a better way for achieving my objective?
If it helps, I haven't defined in
and out
in the path.curve.add_point(position, in, out)
. Is that a mistake? What does in and out mean here exactly?
Thanks!