Dragging and dropping items in first person

Try this:

Pickable.prototype.onMouseDown = function (event) {
    if (this.pickedUp === true && event.button === pc.MOUSEBUTTON_LEFT) {  
        this.entity.reparent(this.app.root.findByName('Root'));
        var point = this.app.root.findByPath('Player/Camera/Point');
        this.entity.setPosition(point.getPosition());
        this.pickedUp = false;
    }
};

ok

Another change:

Pickable.prototype.onMouseDown = function (event) {
    if (this.pickedUp === true && event.button === pc.MOUSEBUTTON_LEFT) {  
        this.entity.reparent(this.app.root.findByName('Root'));
        var point = this.app.root.findByPath('Root/Player/Camera/Point');
        this.entity.setPosition(point.getPosition());
        this.pickedUp = false;
    }
};

ok, sorry about the late reply but, it was showing it anyways for the other one you sent

a bit of a problem, when looking down it flings me out of the map
it works though, I can pick up and drop in the exact spot
also, what if I wanted to stand on the same block?

You can’t with this logic.

Note that you have 3 times the Ammo scripts in your project, maybe harmless, but I don’t recommend it.

ok

I suggest to pick up the entity with the raycast method. Please check the page that I shared in my first post. Then you can use some things of your current script to drag the entity. When I have some time I will create a sample project for this.

Ok, ill check it out and report back to you

I’m doing this between classes when I finish work, so replies will be late, but heres what it shows

This script need to be attached to the entity with the camera component. In your case this is the Camera entity that’s a child entity of your Player entity.

OH ok

its still showing the same thing

oh wait I added it to the player

image

You can remove that line. There you have to reparent and set the position of pickedEntity like you did in your old script with this.entity.

so I just remove it and thats it

Just like I said.

ok