[SOLVED] How to calculate the position including the ___ view?

Hello, here’s a picture so you can understand what we’re talking about:
Capture

“Bottle” position is 1-1 according to bone position, I am trying to create a “regulator” with which I could adjust the position of the “picked” entity

this.tempTest.x = this.entity.children[0].model.model.skinInstances[0].bones[50].worldTransform.data[12];
this.tempTest.y = this.entity.children[0].model.model.skinInstances[0].bones[50].worldTransform.data[13];
this.tempTest.z = this.entity.children[0].model.model.skinInstances[0].bones[50].worldTransform.data[14];

I already understood that the position cannot be setted correctly as simply as this: this.tempTest.x - 1, what should be taken into account in order to calculate the position successfully?

Example: worldTransform.data[12] - 0.07
Capture
The player/camera faces the opposite side
Capture2

Sorry, I don’t understand the question. What are you trying to do at a high level POV?

I want to calculate the new position for a bottle, now the position of the bottle = the position of the bone.

How it should be: Bottle position = bone position + offset

Let’s say I want the bottle to be a bit more to the right, how do I calculate this taking into account where the player/camera is looking? As you can see in the example, when the player/camera is rotated, bottle acts different on all view positions (worldTransform.data[12] - 0.07)

Wouldn’t it be easier to offset it based on the bone’s local XYZaxis so the bottle is always relative to the bone rather than the camera?

1 Like

I’m working with world coordinates to avoid more calculations as I’m also rotating it by camera eulers, so you’re saying that I should make the bottle a child of bone and then position it?

Update: Adding a bottle as a child of bone solves the positioning, why didn’t I thought about that before, will have to recreate the “throw” system

I was thinking more that you would position the bottle along the the bones local axis.

So rather moving it 1 unit in the world X, it would be 1 unit along the bone’s X axis. That way it’s always relative to the bone and not the world.

Got it, thanks! Have one more question, is it possible to have collider rules? I’m “throwing” entities and the only hack I can find is to set the player collider radius to very low value so it doesn’t collide with the entity I’m throwing (as the throwable entity is super near the player), and setting it back after timeout

It is possible but not directly support by the Engine. You have to use Ammo/Bullet Groups and Masks on the rigidbody.

However, if you do this it can break triggers, raycasts etc unless configured as well.

There’s a number of posts on the forum about this and I also did it for this game way back: https://playcanvas.com/project/422705/overview/virtual-voodoo

1 Like