Attention | Topic was automatically imported from the old Question2Answer platform. | |
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()
get_parent().add_child(cube_ins)
cube_ins.set_translation(cameranode.pos3d)