The Daily Click ::. Forums ::. Klik Coding Help ::. collision detection without the use of a collision detection box
 

Post Reply  Post Oekaki 
 

Posted By Message

Chloe Sagal

under the influence of FUN

Registered
  19/02/2009
Points
  607

Orange
19th March, 2009 at 05:31:30 -

im trying to cut down on the ammount of actives per enemy in my project. i started with a sprite, a PMO object, a collsion detector a target and a head sprite. i was able to get rid of the target and the head sprite, i wouldnt know where to start without using the pmo and i thought there might be a way to get decent collsion detection without using a detector box, without worrying about the sprites getting caught in the backdrops or having unclicking the fine detection box

the first thing i came across that prevented me from changing all my backdrops into actives was the collsion mask. i came up with a kind of system to get it working, but there was a problem. it didnt work as well as it did before and when there was a separate object in play, the first one would fall through the cracks and the new on would inherate the collision detection. well, then the next thing i thought of was a loop. it looked good on paper, but i guess the PMO detection script is very jelous of the fast loops and will not work together, and no one was able to get any kind of collsion detection. so, instead of always do loop number of enemy times, i changed the always to the detection script and inside the loop at the beginning added a "on loop, loop index equals pmo, set variable to fixed of pmo" then on every script in the loop i would add "assigned pmo is equal to variable", and it worked just like it did before, the newly created sprite would work, no one else was willing to play nice.

my brain hurts like hell trying to figure this out, but i really need to cut down on the use of actives in my game. if anyone has any ideas let me know. thanks a bunch!

 
Patreon: http://www.patreon.com/chloesagal
Twitter: https://twitter.com/ChloeSagal

Bibin

At least 9001

Registered
  01/07/2005
Points
  308

Silver Cup WinnerGOTW Winner!Has Donated, Thank You!VIP Member
19th March, 2009 at 11:26:08 -

You might want to learn how to make your own custom movement, instead of relying on a fairly locked extension that's not very widely used.

 
n/a

Sketchy

Cornwall UK

Registered
  06/11/2004
Points
  1971

VIP MemberWeekly Picture Me This Round 43 Winner!Weekly Picture Me This Round 47 WinnerPicture Me This Round 49 Winner!
19th March, 2009 at 13:04:00 -

Using a custom platform movement and embedded collision detection would help a lot, and isn't actually that hard.
Unfortunately, it would probably mean scrapping everything you've done so far, and starting over.

There's a very good article explaining embedded collision detection, and plenty of examples and forum posts on custom platform engines (just search).

Here's an engine I was working on a few months ago, incase it helps (it's not terribly well written):
http://cid-b1e7ee094271bbda.skydrive.live.com/self.aspx/Public/Platformer.mfa

 
n/a

OMC

What a goofball

Registered
  21/05/2007
Points
  3516

KlikCast Musician! Guy with a HatSomewhat CrazyARGH SignLikes TDCHas Donated, Thank You!Retired Admin
19th March, 2009 at 13:26:27 -

I thought quite a few people used the PMO extension. O_o

 

  		
  		

Chloe Sagal

under the influence of FUN

Registered
  19/02/2009
Points
  607

Orange
19th March, 2009 at 17:07:20 -

actually, my engine suprisingly does not rely on the PMO as much as you'd think. it would only require as much change to do it as making any of the other changes ive done. all the zombies use their own PMO aside from the player, so relinquishing the zombies of their PMO would only mean adding gravity to them, collision detection and movement. ill start reading up on what i need to do, and ill re-bump this post if i run into any problems. the only other project i know of that actually uses the PMO is captain plokey, and ive even pmed assault andy a few times for some questions cause hes working with jess on the engine(tho he never pmed back).

thanks alot guys, ima get started right away!

 
Patreon: http://www.patreon.com/chloesagal
Twitter: https://twitter.com/ChloeSagal

MBK



Registered
  07/06/2007
Points
  1578

VIP Member
19th March, 2009 at 20:34:26 -

It's easy enough to create collision detection for the main character without any detectors, but I haven't messed around with enemies and AI much as of yet.
As far as I know it should work about the same for both though.

I could probably help you out, but I'm going to expect a line in the credits of your game, people often forget that -.- .
There's an incredibly easy to follow bit of code I've been working on to allow for decent alterability regarding jumping.
E-mail me if you need some more hands-on help than the following.

A good way to deal with collision detection without detectors is to use positional tests and simply remember to use equal and opposite force to stop. If there's a 1 or 2 pixel difference, and you mind it being there, you can offset that with a simple position move event after, as the player will only notice when the character is standing still next to the wall, not whilst in motion.

If you have a complex gravity, speed, friction, acceleration, or directional code, you will need to consider that to make its opposite and equal reaction for stopping.


 
Click Me! http://www.create-games.com/project.asp?view=main&id=1444

http://www.mediafire.com/download.php?aoo1dnnlq5i

Blood of the Ancient One, Seen only as Shadow, Faster than Lightning, Fierce as the Greatest Dragon, Nearly Invisible, Floating in a Dream, Entered through the Demon Door, Destroyer of Evil in a Realm with a Red Sky Scarred, Who could I be ?

Chloe Sagal

under the influence of FUN

Registered
  19/02/2009
Points
  607

Orange
19th March, 2009 at 21:53:47 -

too late, i already figured it out, and there isn't a 1-2 pixle difference. thanks for the help anyways.

 
Patreon: http://www.patreon.com/chloesagal
Twitter: https://twitter.com/ChloeSagal

traugott.simon



Registered
  23/08/2008
Points
  91
23rd March, 2009 at 17:21:42 -

Well in a drow down enemy AI, how could that be made when using backdrops as walls? I ve tried several things for weeks but now again i`m going with for detectors for each enemy. these damned fastloops r eating my cpu so i would be open for another solution.

The main problem is, that if an enemy is touching the backdrop, the object doesnt know whether it is under or above, left or right to the wall. So it doesnt know in which direction it has to be forced.

 
n/a

Sketchy

Cornwall UK

Registered
  06/11/2004
Points
  1971

VIP MemberWeekly Picture Me This Round 43 Winner!Weekly Picture Me This Round 47 WinnerPicture Me This Round 49 Winner!
23rd March, 2009 at 22:52:07 -

Read the article on "embedded collision detection" for a good explanation.
Basically though, for each enemy object you create extra animations which are like your other detector objects.
For example, you create an animation frame which will act as a bottom detector - this is transparent apart from an area at the bottom.
To test for collisions at the bottom, you set the enemy object's animation to show the "bottom detector" frame. You then check for collisions. Finally, you set the animation back to "walking" or whatever. The screen is only actually redrawn after all the events have run, so the player never actually sees the detector frames.
Like I said, the article explains it better.

 
n/a

traugott.simon



Registered
  23/08/2008
Points
  91
24th March, 2009 at 13:02:52 -

Well this is really a good idea, i never thought about this. But i think this is not a solution for my game because my enemy objects have up to 30 different animations.

Will read article later.

 
n/a
   

Post Reply



 



Advertisement

Worth A Click