playMaker

Author Topic: [SOLVED] Melee combat for 2D game  (Read 5059 times)

bizilux

  • Full Member
  • ***
  • Posts: 171
[SOLVED] Melee combat for 2D game
« on: September 13, 2013, 12:35:34 PM »
hello all...

well now that i fixed ranged combat, i went on to do melee combat... i have been trying for few hours, but nothing works as it should...

so the concept of the game is, that you have humans on left side, and zombies on right side... and then you spawn humans and they try to win over their base...


here is a catch... i dont want to use raycast on zombies, because game will be for mobile platform, and i'm trying to save every resource that i can... and from what i've read, raycast is quite expensive to process...  (and i already have raycast on humans, to determine range, when they can start shooting)

the plan is: zombies will follow itween path, and once they collide with other collider(human) they stop moving and start attacking...

for now i dont have itween paths(im doing that later), i simply have translate action... but i still cant seem to figure it out, how to do melee combat without raycast...

this is what i've been trying lately, but this aint working like it should...


and if i can avoid using rigidbody component on my gameobjects... that would be really good too... (but i think one team has to have it right... either humans or zombies)
« Last Edit: September 15, 2013, 12:12:41 PM by bizilux »

bizilux

  • Full Member
  • ***
  • Posts: 171
Re: Melee combat for 2D game
« Reply #1 on: September 13, 2013, 10:30:23 PM »
guys dont be shy :D only 4 views in like 10+ hours? :)

someone must have know a way? :D

bizilux

  • Full Member
  • ***
  • Posts: 171
Re: Melee combat for 2D game
« Reply #2 on: September 14, 2013, 05:41:50 PM »
will i really need to use raycasts? ... shhhhh, bummer  well if they are shot like every 30 frames or something it shouldnt be that huge  of a deal i guess?

MABManZ

  • 1.2 Beta
  • Full Member
  • *
  • Posts: 125
    • MABManZ.com
Re: Melee combat for 2D game
« Reply #3 on: September 14, 2013, 10:12:35 PM »
Raycast really isn't that expensive, do a quick implementation and see how the performance is.

If your game is running on a 2D plane setup you could just make the melee activate if an enemy is within a certain distance (x coordinate), rather than raytracing.

bizilux

  • Full Member
  • ***
  • Posts: 171
Re: Melee combat for 2D game
« Reply #4 on: September 15, 2013, 08:04:31 AM »
Quote
Raycast really isn't that expensive, do a quick implementation and see how the performance is.
i did put raycast on zombies and put it so that it fires every 30 frames... its not that bad, and i think i could get away with it... but you know if there is a better, more optimized way, i would prefer to do that instead...


Quote
If your game is running on a 2D plane setup you could just make the melee activate if an enemy is within a certain distance (x coordinate), rather than raytracing.
well yes thats what i've been asking all  along... what would be any different ways of doing it without raycasting...

the problem is, i wont just have linear movement on x coordinate, i will also have movements on itween paths... diagonally etc...

so i think the best way would be that if collider hits with human collider, then do attack... i just dont know how to accomplish that...

first you start with trigger event, then when it triggers, go into some attacking state, but then when target dies, it needs to send some event to zombie that it died, so that zombie keeps on walking right?  and im not really sure how to do that... im still learning playmaker

i will try to do that now, if anyone has some tips or knows how to do it, etc... im all ears :)
« Last Edit: September 15, 2013, 08:15:32 AM by bizilux »

bizilux

  • Full Member
  • ***
  • Posts: 171
Re: Melee combat for 2D game
« Reply #5 on: September 15, 2013, 10:12:59 AM »
ok i solved it now.... (this tutorial helped alot ... pointed me in right direction)



Edit: looks like i solved it...


will need some further testing... basically what i did was i've put rigidbody on zombie and soldier, and set them to kinematic, and now triggers are working...


yup its working now... nice
this is how i did it:
« Last Edit: September 15, 2013, 12:00:55 PM by bizilux »

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: [SOLVED] Melee combat for 2D game
« Reply #6 on: September 16, 2013, 01:37:26 AM »
Hi,

 I think you should maybe investigate in using Physics triggers more ( if you feel that you are doing too much with raycasting, this is a sign), that would prevent using raycasting for everything. Experiment on the side.

bye,

 Jean