Go Back   kirupaForum > Flash > Game/AI Programming

Reply
 
Thread Tools Display Modes
Old 10-29-2009, 08:33 AM   #1
andiliddell
Registered User
multiple enemys surround the player and not colliding

Something i must have tried 10 times using a variety of different methods.

this link should immediately make you aware of the list of problems...

http://www.thehalt.co.uk/as3/rotateandmove.html

(please bear in mind i will need this to work for upto 8 enemys at a time, and the follow mouse pointer will eventually be changed to follow a player sprite)

1) ive done collision detection before, but how can i get each nme to "jostle" so that their collision circles never overlap, so they dont all end up stacked on top of each other and all seek out the player?

Ive got a variety of different versions of this, none of which have ever really solved this "jostling" behaviour

The example below shows following the player (use cursors to control) but targetting one of six dots around the player so each enemy has a different target to head for....

http://www.thehalt.co.uk/as3/nmeCome7.html

again the overlapping spoils it.

I would be VERY grateful if some legendary AS3 programmer out there can suggest some fixes, or even slaughter my code and tell me how it should be done.

you can download both source code examples for CS4 here...
http://www.thehalt.co.uk/as3/nmejostle.zip

Please help me!!!
andiliddell is offline   Reply With Quote

Sponsored Links (Guests Only) - Register | Need Help?
 

Old 10-29-2009, 09:08 AM   #2
Hangyoo
Registered User
 
Hangyoo's Avatar
Location Hungary-Europe

Posts 46
Hm.I allmost had a thing in my game when called more than one enemy to the stage.




Code:
//Empty MovieClip
 
var container:MovieClip=new MovieClip()
addChild(container)
 
//Calling 3 Enemy to the container_movieclip
 
for(var i:int=0;i<3;i++){
var Enemy:MovieClip= new enemy_mc()
Enemy.x=50+i*10
Enemy.y=100
container.addChild(Enemy)
 
//Under an ENTER_FRAME listener the hitTest
 
for(var i:int = 0;i<container.numChildren;i++){
var enemy_hit:MovieClip = container.getChildAt(i);
if(hero.hitTestObject(enemy_hit){"the action:)"}
 
}
That whay you can call as many enemy as you want and they will reagate with your guy.
But i am just a beginer in this whole as3 programing,so if its not ok for you and dont working,dont hit my but
But i am sure the others will tell you a much proper solvation

Didnt watch your source code ,so sorry if its not what you looking for.

Last edited by Hangyoo; 10-29-2009 at 09:16 AM..
Hangyoo is offline   Reply With Quote
Old 10-29-2009, 10:17 AM   #3
TOdorus
Hot 'n Funky
 
TOdorus's Avatar
Location Nijmegen, Netherlands

Posts 390
What kind of resolvement do you want exactly? I'm thinking of this example: Two enemies stand side-by-side in front of the player, like a wall blocking the player to move forward. The player moves forward, so it'll move into the middle of the "human" wall.

Should the enemies move back? It doesn't matter where on the enemy the player pushes, the enemy gets pushed in the same direction.
Requires vector adittion and recursive checking.

Should the enemies be pushed from each other? The player forces a way through the enemies by pushing in the middle of the enemies.
Requires vector projection and recursive checking.

__________________
Blog: Vipe Games updated 3 dec 2009
TOdorus is offline   Reply With Quote
Old 11-03-2009, 03:19 PM   #4
mxrider108
Skawesome!
 
mxrider108's Avatar
I am struggling with the same thing. Collision resolving can get very complex. Take a look at the thread I started to see what others have suggested:
http://www.kirupa.com/forum/showthread.php?t=335983
mxrider108 is offline   Reply With Quote
Old 11-05-2009, 12:03 PM   #5
_sluimers_
Registered User
Recycle Bin

Here's how I did my loop function, rewritten to fit your code and style.

Code:
function loop(e:Event){ 
   
enemyList.forEach(directEm);

for(var i:String in enemyList) {
    if(enemyList[i].isColliding()) {
        enemyList[i].collide();    
    }
}
    
enemyList.forEach(moveEm);

}
_sluimers_ is offline   Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 06:32 PM.

SUPPORTERS:

kirupa.com's fast and reliable hosting provided by Media Temple. flash components
Creative web apps. Make your own free flash banners and photo slideshows.
Check out the great, high-quality flash extensions. Buy or sell stock flash, video, audio and fonts for as little as 50 cents at FlashDen.

Flash Transition Effects

Flash Effect Tutorials

Digicrafts Components
Flash effects. Art without coding. Upload, publish, deliver. Secure hosting for your professional or academic video, presentations & more. Screencast.com
Streamsolutions Content Delivery Networks Flipping Book - page flip flash component.
Flash-Gallery.com - Get your flash photo gallery (flash component or swf gallery Learn how to advertise on kirupa.com
 

cdn
content delivery network (cdn)

Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd. Copyright 2010 - kirupa.com Copyright 2010 - kirupa.com