Calculating an actor's total velocity

Archive of the old editing forum
Forum rules
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. This forum is archived - please use this set of forums to ask new questions.
Locked
User avatar
ChronoSeth
Posts: 1631
Joined: Mon Jul 05, 2010 2:04 pm
Location: British Columbia

Calculating an actor's total velocity

Post by ChronoSeth »

Can anyone think of a formula which will combine an actor's X, Y, and Z velocity to come up with it's overall velocity in ay given direction?
In case anybody's wondering, I'm was trying to make a melee weapon which deals increased damage based on the player's speed; but I hit a stall here. It wouldn't make much sense to have increased damage when you are running forward but not if you strike when falling. :?
Edward-san
Posts: 1774
Joined: Sat Oct 17, 2009 9:40 am

Re: Calculating an actor's total velocity

Post by Edward-san »

Do you mean the norm of the velocity vector? If yes, then use this value: sqrt ( velx*velx + vely*vely + velz*velz )

[edit]whoops i failed to read the last sentence... so you don't need the velz thing. Just [ sqrt ( velx*velx + vely*vely) ].
Last edited by Edward-san on Sat Apr 30, 2011 3:58 pm, edited 1 time in total.
User avatar
XutaWoo
Posts: 4005
Joined: Sat Dec 30, 2006 4:25 pm
Location: beautiful hills of those who are friends
Contact:

Re: Calculating an actor's total velocity

Post by XutaWoo »

So don't factor in z velocity?

As for your question, it would probably be something akin to abs(velx)+abs(vely). (4*((abs(velx)+abs(vely))/40))+3 would do 3 damage minimum, 7-ish maximum. 40 is an assumption of the maximum player speed (with straferunning), so you'll need to adjust it if it isn't the default speed.

Alternatively, you could go with a lower divisor and remove the 4* to just get a straight value based on speed; just make sure it's divided by something, or else the weapon would get truly rediculous.

e:f;b, though I have another method.
User avatar
David Ferstat
Posts: 1113
Joined: Wed Jul 16, 2003 8:53 am
Location: Perth, Western Australia
Contact:

Re: Calculating an actor's total velocity

Post by David Ferstat »

Locked

Return to “Editing (Archive)”