Jump to content

Getting velocity sum


Code_Man

Recommended Posts

I have a little odd problem, i try to get the absolute sum of all fields from velocity, the speed so speak.

However when i get an output that looks like "00" or "x.z.y" where x y and z are numbers when i use the following code.


%v = %obj.getVelocity();

echo(mAbs(getWord(%v, 0)) + mAbs(getWord(%v, 1)) + mAbs(getWord(%v, 2)));


I dont know whats wrong and is there some kind of function builtin perhaps to save me the code mess?

Link to comment
Share on other sites

I need the speed of the player to implement weapon accuracy modifiers based on it.


The code i posted is the very one i am using in a function that gets scheduled every second once player spawns, %obj is the player in this case.


Since there is no other callback function that i can check if the player is moving i probably rely on this method.


I also noticed there is no "walking" pose in getpose(), i dont exactly know what pose is meant to represent, but its odd there is a sprint pose but no moving pose.

Perhaps in the future it should be extended to cover player movement.


Cant post the whole thing right now cuz its on my other pc.


Im not much of a math person, im not sure if vectorlen is what i really want but i suppose it should be close enough, can adjust it later if need be.

Link to comment
Share on other sites

  • 2 weeks later...

Bad news, seems that just setRotation actually changes velocity even when i remain in the same spot.


Not sure how to work my way around this other than implement my own kind of velocity check that accounts for differences in position only.


What the hell is going on here?

Any alternative suggestions?

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...