how to get 3d click position?i want add cube instance to click position like minecraft.

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By bgegg

i use project_position of camera.but it add cube to character position.
how to get hit point?Does it work without collisions?

this is script of camera and character

extends Camera

var pos2d = Vector2()
var pos3d = Vector3()

func _process(delta):
	pos2d = get_viewport().get_mouse_position()
	pos3d = project_ray_origin(pos2d)
	return pos3d

this is character script

extends KinematicBody
var cameranode

var cube = load("res://levels/cube.tscn")

func _ready():
	cameranode = get_node("Camera")
func _physics_process(delta):
	if Input.is_action_just_pressed("mouseclick"):
		var cube_ins = cube.instance()
:bust_in_silhouette: Reply From: a human

I would use a raycast moving from the player in the direction of the mouse, and if it collides with another block when you click make it add one.