0 votes

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)
in Engine by (186 points)

1 Answer

0 votes

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.

by (114 points)
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.