Jump to content

Recommended Posts

I can get a players weapon direction vector with
 

dir = player weaponDirection (currentWeapon player);

That represents the normal vector for the direction of the weapon in world space as far as I know.

The question is, how can I translate it to the modelspace of the player?

EDIT:
What do I need that for?

I ve a point at players weapon in players model space, in this case the IR Laser mount point.
I want to change the point accordingly to the change of the weapon direction in model space.

Share this post


Link to post
Share on other sites

I can get a players weapon direction vector with

 

dir = player weaponDirection (currentWeapon player);
That represents the normal vector for the direction of the weapon in world space as far as I know.

The question is, how can I translate it to the modelspace of the player?

 

 

Add dir to your position and transform the resulting position to modelspace. Result will be the vector of your weapon in modelspace ;)

Share this post


Link to post
Share on other sites

Add dir to your position and transform the resulting position to modelspace. Result will be the vector of your weapon in modelspace ;)

Okay, that would mean that the length of the vector from model spaces origin to the weapon is always 1 and that if I lean, kneel down or crouch the origin of the model space is moving related to my behaviour?

Share this post


Link to post
Share on other sites

Okay, that would mean that the length of the vector from model spaces origin to the weapon is always 1 and that if I lean, kneel down or crouch the origin of the model space is moving related to my behaviour?

 

Ooops, my bad. There will probably be a small deviation in the vector. You can use player selectionPosition "RightHandMiddle1" to get the modelspace coordinates of your hand. Transform it to worldspace to get the weapons position, add the aimvector and transform back to modelspace where you substract it from the modelspace weapon position again. Result should be aimvector in modelspace.

  • Like 1

Share this post


Link to post
Share on other sites

Ooops, my bad. There will probably be a small deviation in the vector. You can use player selectionPosition "RightHandMiddle1" to get the modelspace coordinates of your hand. Transform it to worldspace to get the weapons position, add the aimvector and transform back to modelspace where you substract it from the modelspace weapon position again. Result should be aimvector in modelspace.

that sounds much better :-) Thank you

Share this post


Link to post
Share on other sites

 

Yep, basically what I said above but already in code  ;)

You still need to replace the [0,0,0] with player selectionPosition "RightHandMiddle1"  to make it work with soldiers (not just vehicles). AFAIK the soldier [0,0,0] position is somewhere near the belly.

Share this post


Link to post
Share on other sites
player weaponDirection (currentWeapon player);

You can also simply add that vector to the player-position and then use the worldToModel command on it.

 

Another easy option would be to use an invisible dummy-object that you attach to the "RightHandMiddle1" selection. Then you can get vectors directly from that object.

Share this post


Link to post
Share on other sites
player weaponDirection (currentWeapon player);

You can also simply add that vector to the player-position and then use the worldToModel command on it.

 

Another easy option would be to use an invisible dummy-object that you attach to the "RightHandMiddle1" selection. Then you can get vectors directly from that object.

 

 

The dummy is not needed anymore as you can get the modelspace position of memory points (as I said above).

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

×