which it the fastest and most effective way?

Community Forums/General Help/which it the fastest and most effective way?

NotAGamer(Posted 2016) [#1]
which it the fastest and most effective/efficient way in detecting if my character hit the enemy(or other things). should be fast ..
(multiple enemy or things)

A) check my_player_distance and other_entity_distance (meaning to all entities) then check if my_player is animating the attack_animation
then apply the damage

B) check what animation player is doing... if attack animation,,
then check the nearest entity if what entity(object or enemy)
then check if near enough to be hit then do the damage..

or any other algorithms please..

and is it wiser to use collision? or raycast? or is there anything else?

please help..

thanks


xlsior(Posted 2016) [#2]
You can do a rough check first (quick compare of the distance between the two objects), and only do the actual collision checking if they are reasonably close enough to collide


Kryzon(Posted 2016) [#3]
The fastest way is not do to something at all.
You shouldn't check for collisions if the player is not attacking--or not doing something else that needs collision tests against enemies.

If you do need those collision tests then I agree with xlsior that you can avoid redundant tests by using simpler, very quick tests that tell if the entities are even close enough to collide (like being in the same leaf of a quadtree, for example).


Derron(Posted 2016) [#4]
Atack animation =/= attack action

So instead of checking while animating.. you only animate if the check says "in range".


Simple methods:
- check boundingbox intersections
- compare current grids (grids are neighbours or not?) ... if grid based
- quadtrees (on moving a unit you update on which leaf it resides)

Bye
Ron


NotAGamer(Posted 2016) [#5]
thanks for the replies :) helps me so much..
by the way it is a hack and slash like monster hunter ..
using xors3d


Matty(Posted 2016) [#6]
Speed considerations:

Number of enemies to test - more than a few hundred - optimisation possibly required.
less than 20 - can do less efficiently with little or no hit to the performance of the game.

If it is 1-1 can do full checking 'does fist mesh hit opponent and where'

If it is 1-100+ most likely do simply grid checking 'during attack animation is an enemy in the grid next to me'

If it is 1-10+ most likely do something like 'during attack animation is an enemy in front of me and near me'

Gives you an idea...play around with the numbers.


NotAGamer(Posted 2016) [#7]
@Matty

thank you very much for the numbers :)