Sockman Posted September 19, 2008 Report Share Posted September 19, 2008 And you guys thought I wasn't doing any fangame work... Anyway, I've been trying to implement some sort of basic gravity/physics mechanic with enemies, and I've been making some attempts that haven't succeeded. I tried using the Platform Movement object to try and handle gravity for all non-flying enemies (If an enemy flies or hovers, it's flagged and excluded from gravity events), but the extension outright ignores you when it's assigned to more than one object. I know it's possible to implement decent enemy physics (Y HALLO THAR, MECHA MADNESS), but I'm stumped when it comes to finding an event-light, CPU-friendly method of doing so. What would be the best approach to implementing simple enemy physics? Please and Thank You. Link to comment Share on other sites More sharing options...
Serephim Posted September 19, 2008 Report Share Posted September 19, 2008 AI is something you have to be good at to get just right, but as for enemy physics, i guess the best way to do it is to find the easiest way around things. I myself to this day try and find extremely cleaver ways around MMF2's object selection issues, but if you know what you're doing you can still make pretty good Sensorless enemy movement. Just do it the same way you would do static, but alter it to not use the ground sensors. This is way harder with enemies who have sprites that like to change on the Y axis as they animation, but still pretty useful if you know how to find ways around those kinds of things. (Hotspots, ect) And to make up for the lack of side sensors, you can do what i do -- place sensors on the sides of the walls and ceilings, and make sure the movement events for the enemy all have (Enemy is not colliding with (whatever sensor) checked on for the respectful movement axis. And finally, just make sure your level design refrains from putting enemies next to slopes and terrain you know they wont operate on correctly. Link to comment Share on other sites More sharing options...
LarkSS Posted September 19, 2008 Report Share Posted September 19, 2008 When I did AI in MM, I didn't use extensions nor object sensors. It was as simple as using collision masks ( see dami's ring loss engine for its collision routine ) alongside with a fastloop that runs seperate checks for each object to handle each one correctly. Link to comment Share on other sites More sharing options...
Serephim Posted September 20, 2008 Report Share Posted September 20, 2008 Yeah, i dont see the need for object sensors or anything in AI unless it has extremely complex patterns that involve rugged terrain. Espically not for a Sonic badnick anyway, who's only purpose is to maybe dash around a few times before hes jumped on / spindashed / rolled into. Link to comment Share on other sites More sharing options...
DimensionWarped Posted September 20, 2008 Report Share Posted September 20, 2008 When you have a complex physics system on every single enemy in the game, I'd say yes, a few sensors become necessary... or at the very least, something to detect slope. On the other hand, thats entirely too taxing in MMF. In this instance, MMF falls behind to hand-typed languages. Link to comment Share on other sites More sharing options...
Serephim Posted September 20, 2008 Report Share Posted September 20, 2008 well not really. Only if you are unsure on if you want them automated or scripted in. If you know exactly how many enemies youre going to place somewhere, then you can just copy/paste their code and create new sensors for them. Otherwise you're stuck with sensorless AI. Like i said, its all about finding the easiest way around things. Link to comment Share on other sites More sharing options...
LarkSS Posted September 21, 2008 Report Share Posted September 21, 2008 Really, if you make the enemies 'sleep' outside of the window, set up a simple object management system to keep the numbers low, and program them so that collisions/identity checks are kept to a minimum, then speed doesn't become that severe of an issue. I got lazy on MM and didn't feel like optimizing it as much as I should; that and the amount of enemies used in it were probably a bit over the top. Link to comment Share on other sites More sharing options...
Streak Thunderstorm Posted September 21, 2008 Report Share Posted September 21, 2008 And for not optimizing it, I'm raging @ you. RRRRAAAAGEEE Link to comment Share on other sites More sharing options...
DimensionWarped Posted September 21, 2008 Report Share Posted September 21, 2008 well not really. Only if you are unsure on if you want them automated or scripted in.If you know exactly how many enemies youre going to place somewhere, then you can just copy/paste their code and create new sensors for them. Otherwise you're stuck with sensorless AI. Like i said, its all about finding the easiest way around things. Copying and pasting code is completely unnecessary. Just use a qualifier. And he wants a physics system, not a bouncing ball system. And going on how taxing just the bouncing ball style is, a highly realistic physics simulation attached to a large number of enemies in MMF would rape just about any machine. And it isn't like there is a whole lot you can do to optimize in MMF... Especially with every little thing causing you to lose object focus. Link to comment Share on other sites More sharing options...
Serephim Posted September 21, 2008 Report Share Posted September 21, 2008 Copying and pasting code is completely unnecessary. Just use a qualifier. It doesnt work. By copy/pasting i mean create entirely new entities that have the same events so MMF doesn't mix them up. Link to comment Share on other sites More sharing options...
Sockman Posted September 21, 2008 Author Report Share Posted September 21, 2008 All I really want is a way of implementing some sort of gravity for enemies without using, like, a gazillion sensors. I guess I could use ground sensors for each one, but that's going to be major rape in the larger levels. Damn you MMF2, why can't you have the same edge detection for objects that you have for window and frame edges? There's two reasons why I'm wanting such a gravity/physics system: 1. I want enemies to move and react to Sonic's attacks. (IE: A badnick gets knocked back a little if Sonic punches him in the face.) 2. I don't want to put up invisible sensors on the edge of every platform to prevent enemies from wandering off the edge and "flying". If a gravity system were to exist, the enemy would just fall to the ground and keep walking. Link to comment Share on other sites More sharing options...
LarkSS Posted September 22, 2008 Report Share Posted September 22, 2008 Just use collision mask checks at the bottom-left and bottom-right of the badnik. If collision on the bottom-left becomes false, then move the badnik right, and visa versa. Also, if any one of the two collision checks is true, then you can turn off any vertical speed to simulate the enemy smacking the ground. If you want multiple enemies to work effectively like this, the best way is to run a fast loop for the amount of enemies there are. Then spread 0 through an alterable value in the enemy ( I'll use value Z in this example ). This value will be used to give each enemy a unique identifying number. Now for any event that you use a collision mask check in, at the top of the conditions put an Onloop condition of the loop that you're running and beneath that put a comparison ( you MUST use an alterable value comparison from the enemy object, not a general value comparison ) that checks if the enemy's value Z ( or whatever you used ) is equal to the loop's index value. If any confusion exists, let me know; I have no problems whipping up a quick example. Link to comment Share on other sites More sharing options...
Sockman Posted September 22, 2008 Author Report Share Posted September 22, 2008 Just use collision mask checks at the bottom-left and bottom-right of the badnik. If collision on the bottom-left becomes false, then move the badnik right, and visa versa. Also, if any one of the two collision checks is true, then you can turn off any vertical speed to simulate the enemy smacking the ground.If you want multiple enemies to work effectively like this, the best way is to run a fast loop for the amount of enemies there are. Then spread 0 through an alterable value in the enemy ( I'll use value Z in this example ). This value will be used to give each enemy a unique identifying number. Now for any event that you use a collision mask check in, at the top of the conditions put an Onloop condition of the loop that you're running and beneath that put a comparison ( you MUST use an alterable value comparison from the enemy object, not a general value comparison ) that checks if the enemy's value Z ( or whatever you used ) is equal to the loop's index value. If any confusion exists, let me know; I have no problems whipping up a quick example. I think I'm getting the gist of what you're saying (I think...), but an example would not only be helpful to me, but it would be helpful to anyone else who encounters the issue in the future. At your convenience, of course. Link to comment Share on other sites More sharing options...
LarkSS Posted September 23, 2008 Report Share Posted September 23, 2008 I'll edit my post soon with the example; just posting in the first place to let you know I'm on it. Edit: Eh, tomorrow; I need to make up for my lack of sleep. That and creating a 360 engine is very taxing and I need a break from any more programming tonight. Edit2: Alright so, it's done. It's just a basic engine that shows you how to perform safe collision mask checks among multiple objects ( in a qualifier no less ) as well as applying a simple gravity and repositioning system to them. Hope this helps. Download AIExample (Build R244 or greater is required) Download Mirror 1 Link to comment Share on other sites More sharing options...
sonikku x Posted August 30, 2013 Report Share Posted August 30, 2013 Thanks for this Link to comment Share on other sites More sharing options...
Recommended Posts