Which is faster ?

Blitz3D Forums/Blitz3D Programming/Which is faster ?

NotAGamer(Posted 2015) [#1]
im making a blitz3d hack and slash game and what to know which is faster to use in determining if the player hit the enemy..

will you use

"entitydistance" or "entitycollided"

and where will you place it..

before checking tha animation frame of the model(if its in attacking animation)

or after checking the animation frame?

which is which ?

thanks guys..


Yue(Posted 2015) [#2]
Use LinePick It is the best.


NotAGamer(Posted 2015) [#3]
@yue

oh, i yeah.. forgot that i can use line pick ..
thanks..

if you could give me an algorithm to compare whats in my mind that would be better though :) thanks !


Yue(Posted 2015) [#4]



EntityPickMode enemy,2,1
collisionEnemy% = LinePick (EntityX(player%),EntityY(player), EntityZ(player%, 0, 0, 100)) 

If collisionEnemy% = enemy% Then 
	
	; Enemy dead.
End If 





RemiD(Posted 2015) [#5]

which is faster to use in determining if the player hit the enemy


If you want to detect a collision between a shape and another shape (not necessarily sphere -> shape), you can use entitydistance, then if near enough, meshesintersect (but you can not retrieve the point and normal of collision), or several ellipsoids childs of a pivot and when you turn move the pivot the ellipsoids will follow (you can retrieve the point and normal of collision), or maybe coldet shapes (but sometimes it behaves weirdly, not sure if it is reliable...)
Linepick can be used but not if the shape which must provoke the collision has an irregular shape (not a sphere) (it can be used but it will be complicated...)
If you want a simple system you could only check if one character faces another character (with deltayaw) then check the animation frame to know if the weapon is in a position orientation where it can hurt the other character (with animtime).


Matty(Posted 2015) [#6]
How accurate do you want it?

Do you want to know where on the model exactly the hit took place (ie left wrist)?

Or are you happy to simply know that the attacker was a few feet away facing the enemy when he swung his sword?

The second is dead easy, the first is trickier.


NotAGamer(Posted 2015) [#7]
@matty

i actually want the first one you said..
by having such detail i can know what type of "die animation" i need to play...


Matty(Posted 2015) [#8]
In that case you most likely are after some kind of mesh intersection routine which applies to animated meshes.

One of the issues with blitz3d linepicks and collision commands is that when applied against animated meshes they default to the root/base pose regardless of what frame the animation is currently on.

Assuming the sword itself or other weapon is separate to the character swinging it (ie it is simply parented to the hand) then you can calculate the position of the sword tip with a pivot placed appropriately and the position of the impact using entitydistances and pivots placed at the location of bones in the target model.

For example:

When the sword is swinging loop through the enemy's bones (pivots) and calculate the distance from the sword tip to each bone pivot. If it is within a threshold distance, and is the closest then you can assume the sword has struck that bone (eg the neck bone or the thigh bone etc).

That is probably going to be the easiest way to handle this. You can then work out whether you need a decapitation (ie neck bone struck with sword/axe point) or whether the enemy is having his/her legs taken out from under them (struck on knee eg).

Regarding speed:

Is this a 1 on 1 combat game - if so will be very quick.

Is this a 1 player versus many enemies (5+ at once) - then it should still be quick if done right.

If this is a 5+ versus 5+ battle raging then doing this for every sword swing will cause a bit of grief looping through all those bones each frame the sword swings....perhaps....it can be optimised.


NotAGamer(Posted 2015) [#9]
out whether you need a decapitation



you mean i can do that in real time in blitz3d?


RemiD(Posted 2015) [#10]
Or have low tris shapes which have approximately the same shape than the body parts of your character, and set each shape as a child of the appropriate joint, and also have a low tris shape for the damage causing part of your weapon, and set this shape as a child of the weapon, then when the character is attacking, check if another character is near enough and if yes, check if the low tris shape of the weapon intersect with a low tris shape of a body part of the other character.

If you use low tris shapes, and if you use a distance check before using meshesintersect, this will be fast enough.


Matty(Posted 2015) [#11]
Yes you can do in real time.....theyre all just smoke and mirrors really though.