Rick Posted March 2, 2012 Share Posted March 2, 2012 In games like Diablo where you mindlessly just kill things and you don't have a target, what is the best way to implement melee attacking? These games seem to have very fluid systems for melee attacks which aren't very presice in their targeting. Do they use physic bodies around the weapon itself, do they just do a cone in front of the player and just damage everything inside this cone when the player attacks? Just curious if anyone has an idea about how best to get that same smooth attacking style. Quote Link to comment Share on other sites More sharing options...
DigitalHax Posted March 2, 2012 Share Posted March 2, 2012 One way to do it is code a physical object using something similar to the bullet code, and set a range to how far it can go before deleting itself. Or. You could use some of the ways you described. You would have to have already made your own hp/damage system regardless, but I am not overly sure. Quote Win7 64bit, Leadwerks SDK 2.5, Visual Studio 2012, 3DWS, 3ds Max, Photoshop CS5. Life is too short to remove USB safely. Link to comment Share on other sites More sharing options...
paramecij Posted March 3, 2012 Share Posted March 3, 2012 I don't know how the games you mentioned do it, but I would first try something simpler than physics.. I think it can be done reasonably well with just two checks (distance & angle): - if the enemy is inside the melee range of the player ( governed by the players current weapon length or reach ) - and if the player is facing the enemy ( or rather if the enemy is inside the weapons angle of attack ) - dish out damage to all who qualify or only the closest one(s) Simple and easy to extend, for example you could specify different angles or field-of-damage for each move so you could have 180° backward axe spins etc, just set the proper ranges for the move/animation and it's done. Maybe even add a "Leap to enemy" special power - easy, just multiply the weapons reach, and move/animate the player towards the enemy.. .. maybe this is what you meant with the "just do a cone in front of the player and just damage everything inside" ? 1 Quote Link to comment Share on other sites More sharing options...
gamecreator Posted March 3, 2012 Share Posted March 3, 2012 I think it's safe to guess they don't use physics bodies around the weapons because what happens if there are even just a few frames skipped? Many swings being only a fraction of a second, you might miss the collision check entirely. Your cone idea is probably the way to go. Quote Link to comment Share on other sites More sharing options...
Aily Posted March 3, 2012 Share Posted March 3, 2012 If i would make such game - i will make physics body with form of punch area, attach it to player controller, make it collide with enemyes with responce "2", and on collide callback get enemy entity, get it user data (GameObject class), and do it player_hit() function. Quote "Better" is big enemy of "good" Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.