I have also noticed that the way i get the initial position of the object to be thrown. as far as i can tell, there is no .get_position() in 3d, only .get_global_transform(). I have tried:
object.set_global_transform(self.get_node("Head").get_global_transform())
This spawns the object in the right pace but with some strange initial impulse. I don't know how to explain this ?.
@xyz said:
Simplest way would be to take camera's local look direction (always negative z axis), project it into global space and multiply with strength of the impulse:
var impulse_vector = camera.to_global(Vector3.FORWARD).normalized() * impulse_strength
this is kinda working, but the direction of the throw is only influenced by the position of the character and not the direction the camera is facing ?.
@cybereality said:
Hey there! Yes, I have some experience with this.
First you need to obtain the forward vector. You can do this for the character like this:
var forward_vec = Vector3(0.0, 0.0, -1.0)
var basis = get_transform().basis
var forward = basis.xform(forward_vec)
So now forward will be facing toward wherever the character is looking. Then you can move the object like this:
object.apply_central_impulse(forward * throw_speed)
That should work.
As far as I can tell this:
var forward_vec = Vector3(0.0, 0.0, -1.0)
Is the direction the object is thrown in. How can I set this to the direction the character is looking ??