-
fastloops for basic enemy controll (platformer)
Hi everyone,
http://www.holymonkeystudio.com/temp/Help2.zip
Here is a quick example MFA of fastloops being used to control basic platformer enemy movement and gravity. There are better and more elaborate examples around, but this is was a direct response to a help request, and is intended for someone who is still quite new to MMF in general so I tried to keep it as simple as possible.
-
Re: fastloops for basic enemy controll (platformer)
Thanks a TON. I couldn't find an example like this anywhere. I'm going to be using this a lot. My game isn't too huge on memory so this will work PERFECTLY. Thanks a lot for your help and sorry about asking the question so many times, it just drove me crazy why i couldn't find it anywhere.
Thanks again!
-
Re: fastloops for basic enemy controll (platformer)
Hmm well i have another situation where i need to select instances. But i need to know more about mmf2's selection process. How, and when does mmf2 select an instance? Is it ANY code that iterates through to all copies of something? I want to know documentation or an explanation on how mmf2 selects copies. I know how to do it with code, but i want to know y, and what other functions or etc cause it to select instance copies. I know collision and overlaps do, but is their any way to check collision and then select a copy of a different object that "matches" its spread value? Like treating pairs of objects that are different objects? And doing something with one object when you overlap a "test" invisible square object? It works when there is one but i need to select the pair that goes with each "test" object.
-
Re: fastloops for basic enemy controll (platformer)
Can't you just pair it without matching them by ID? Unless you ran out of the 26 alterable values and the 13 alterable strings, you wouldn't need to specifically match pairs of objects.
-
Re: fastloops for basic enemy controll (platformer)
How would i "pair" objects together? Is it a "start of frame" function?
-
Re: fastloops for basic enemy controll (platformer)
MMF2 does it for you.
Say you have 3 object A and 3 object B. If you do always: set position of obejct B to 0,0 from object A, then MMF2 would automatically assign one Object B per Object A. It can be thought of as object distribution.
-
Re: fastloops for basic enemy controll (platformer)
okok, but how would i do something like:
When "player" overlaps "collision box" then "destroy block that is above collision box" and then create "destroy animation particles"
If i do it directly, it will destroy all blocks, no matter which copy of the collision box i overlap.
-
Re: fastloops for basic enemy controll (platformer)
That's why you make the collision box part of the animation ;)
-
Re: fastloops for basic enemy controll (platformer)
huh? i have a collision box (as my block that explodes is static) and when my collision box is overlapped the box is "destroyed" and pieces are created at a spot above the box. I dont get what you mean.
-
Re: fastloops for basic enemy controll (platformer)
I mean that whichever object has the animation that is visible onscreen, can aslo contain a collision box animation that you use to test for collisions. It is a matter of switching to that animation, then checking for collisions, and then switching back to the previous animation so that the player stills sees the animation as they normally would. Like this; for example:
-Always: Set Alt Val A to Anim of Object, Set Alt Val B to Anim Frame of Object, Force animation to Collision Mask
-Collision betweenObject and Spike: Destroy Obejct
-Always: Set Animation to Alt Val A, Set Anim Frame to Alt val B
-
Re: fastloops for basic enemy controll (platformer)
ok that does make sense. Ill try it, even though i would like an MFA showing a simple way using that method, but ill try it. If you want you can make an mfa of it, itd be a big help, but i dont want to be a nag by asking as you probably are busy.
-
Re: fastloops for basic enemy controll (platformer)
This was great help indeed, just what I was looking for! But as always, I get an issue. My player uses "Gravity", and since the enemies here do aswell, they *** up the jumping of my player :(
Is it possible to make a second Gravity function, or make it work separate or something? My Gravity is like DavidN's fastloop tutorial + the one I have here.
-
Re: fastloops for basic enemy controll (platformer)
Run a different loop... ? I am not sure, what is not working correctly here?
-
Re: fastloops for basic enemy controll (platformer)
Hmm, maybe I have misunderstood something. If I change the loop's name in this tutorial from "gravity" to "gravities", will it make any difference? I though loops named gravity had some special gravity functions or something... But it seems to work.. Just asking to be sure.
-
Re: fastloops for basic enemy controll (platformer)
The names of loops can by anything you want. They don't impact how the loop behaves.
-
Re: fastloops for basic enemy controll (platformer)
Ah okay, well that makes the best sense :D Everything works now then :) Thanks, LB, and thanks HolyMonkey for example :)
-
Re: fastloops for basic enemy controll (platformer)
I have another question regarding the way this example works. If I would make two events that looked like this:
Bullet is overlapping Group.Enemies
= Substract 25 from Alterable value D
Alterable Value D of Group.Enemies is lower or equal 0
= Destroy Group.Enemies
Would something go wrong?
I have of course added the Group.Enemies to the enemies, but its something weird going on. When one of them are destroyed (Less than 0 in Alterable Value D), another enemy seems to just stop moving. He is not destroyed or anything, he just stops moving. What can cause this?
-
Re: fastloops for basic enemy controll (platformer)
Nothing should go wrong as long as you don't use Compare Two General Values on that second event there. Did you make sure to use spread value on the enemies again?
-
Re: fastloops for basic enemy controll (platformer)
I have not touched anything on Alterable Value A, B or C.. Only D which was free. I dont fully understand how these events works, so it could be I need to change something in one of them. But which? The Spread value (Alterable value C if Im not mistaken) is in almost all the events.. Do I need to change one of them?
-
Re: fastloops for basic enemy controll (platformer)
Well when you destroy an object that leaves a gap in the spread values:
0,1,2,4,5,7,8
So to fix it you have to use Spread values again, probably in an Always event. Make sure to use spread value by itself and not in the same even as fastloops are started on.
-
Re: fastloops for basic enemy controll (platformer)
Are you able to check the example?? It would be super appreciated.. I cant really find a fiting place to add any such events :(
-
Re: fastloops for basic enemy controll (platformer)
sorry to jump in here but i also did not know that if you destroyed an object that it would leave a gap in the spread values as LB has said i wounder if LB could explane in more depth of how to spread value by itself and not in the same event as the fastloops.
-
Re: fastloops for basic enemy controll (platformer)
Always: Spread value 0 in object
...The end.
-
Re: fastloops for basic enemy controll (platformer)
Im gonna finish a few other events, then its a general test on this. But so far, I think its actually working! Thanks :D
-
Re: fastloops for basic enemy controll (platformer)
One more thing appeared.. What if I want the enemies to switch direction when they hit each other aswell??
-
Re: fastloops for basic enemy controll (platformer)
That part doesn't need to be on a fastloop. Just Enemy Collides with Enemy: Set enemy direction to Dir( "Enemy" )+16
-
Re: fastloops for basic enemy controll (platformer)
Hmm, didnt work when I tried :(
Collision between Group.Bad and Group.Bad
= Set Direction to Dir("Group.Bad")+16
-
Re: fastloops for basic enemy controll (platformer)
I don't see why that doesn't work. What happens when the enemies collide?
-
Re: fastloops for basic enemy controll (platformer)
Nothing, they walk straight through each other :S
-
Re: fastloops for basic enemy controll (platformer)
I cant help but feel a little clever. I replaced the X movement alterable value (Which in this case was Alterable Value A) with flags. The movement works like if A.V. A is 0, it moves one way, and 1, it moves the other way. I replaced all this with Flag 0 is off is moving one way, and flag 0 is on is moving another way. When they collide, I made an event that toggled the flag, and now it works :)
-
Re: fastloops for basic enemy controll (platformer)
OH! I thought they moved based on direction, if they move based on alterable value then it's just Set Alt value to 1-Alt val
-
Re: fastloops for basic enemy controll (platformer)
I tried what I though would work as alterable values at first, which was
Enemy collides with Enemy
+ Alterable Value A = 1
= Set Alterable Value A to 0
Enemy collides with Enemy
+ Alterable Value A = 0
= Set Alterable Value A to 1
But this ended up with just seting one of the enemies alterable value to the other, so it ended up with a line of enemies walking the same direction like a .. pilgrimsadventure (lack of English words). But a toggle would kinda FORCE it to work :]
-
Re: fastloops for basic enemy controll (platformer)
Eh, you should read this:
http://www.clickteam.com/epicenter/ubbthreads.php?ubb=showflat&Number=176557
-
Re: fastloops for basic enemy controll (platformer)
Aight, this will be looked into :)
-
Re: fastloops for basic enemy controll (platformer)
After reading that, re-read this and you should see why it doesn't work. ;)
Quote:
Originally Posted by FlinkGigitty
Enemy collides with Enemy
+ Alterable Value A = 1
= Set Alterable Value A to 0
Enemy collides with Enemy
+ Alterable Value A = 0
= Set Alterable Value A to 1
-
Re: fastloops for basic enemy controll (platformer)
Im not really able to relate it to my events.. It was helpful info, but I cant really compare anything to why my event does as it does.
-
Re: fastloops for basic enemy controll (platformer)
OK, What is happening is that the Enemy collides with Enemy is triggering both events. The first event looks for alterable value A to be 1. Let's say it is. It then sets it to 0. The next event looks for alterable value A to be 0, and because it was just set to 0 in the previous event, it is true, and therefore sets it back to 1 again. THis means that alterable value a will only ever be 0 between the two events, and all other times be 1.
-
Re: fastloops for basic enemy controll (platformer)
Ah, yea.. you mean its one action from MMF each time its done reading??
And anyway, whats your solution to it?? What events would you replace it with?
-
Re: fastloops for basic enemy controll (platformer)
Enemy collides with Enemy: Set Alt Val A to 1-Alt Val A
-
Re: fastloops for basic enemy controll (platformer)
Haha, thats also clever :P
I should've paid more attention to math in school