Posted By
|
Message
|
JetpackLover
Registered 01/03/2007
Points 212
|
17th January, 2009 at 05:43:55 -
The enemies I have in my game are stationary and are all duplicates. What I want to do is have it so if you get within a certain range an attack animation will play. I have already spread my values by 1 but unfortunately it appears that when I try to have code that has to do with position MMF doesn't know which one I'm talking about. The code I have now is like this
(This code turns off a flag, and that flag plays an animation)
+X position of(Hitbox) >x of (pot snake)+50
+ID of (Pot snake)=1
+Only one action when event loops
>Set internal flag 0(Pot snake) off
(This code turns off a flag, and that flag plays an animation)
+X position of (Hitbox)<x of (pot snake)-50
+ID of (Pot snake)=1
+Only one action when event loops
>Set internal flag 0(Pot snake)off
(This code turns on a flag when you are inbetween the pot and that flag plays an animation)
+X position of (Hitbox) <x of (pot snake)+50
+X position of (Hitbox) >x of (pot snake)-50
+Only one action when event loops
>Set internal flag 0(pot snake) on
+(Pot snake)internal flag 0 is off
+Only one action when event loops
>Change animation(pot snake) to Crouch down
+(Pot snake) internal flag 0 is on
+Only one action when even loops
>Change animation(Pot snake) to Stand up
So yeah, anyway got any advice?
http://www.invincibletime.com/
Devlog for HD MMF Game Omulus. Check it out because it's gonna be awesome. http://omulus.tumblr.com/
Follow me on the twitters https://twitter.com/JetpackLover
|
MBK
Registered 07/06/2007
Points 1578
|
17th January, 2009 at 09:52:24 -
There's a simple way that might work, but you'd need to test it to be sure.
You could change the Pot Snakes animation frames so that it's larger, then set the hotspot to its head (of the frame you want it to hurt the player that is) ... then when the character overlaps the invisible part of the snakes animation, the pot snake pops out at him and does his attack animation.
That might not work in all situations though, but it's one possible solution.
It would be nice to know the proper way to solve this though, so if anyone out there knows what it is feel free to help out.
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 ?
|
Sketchy Cornwall UK
Registered 06/11/2004
Points 1971
|
17th January, 2009 at 14:25:51 -
Dudehuge: That's massively over-complicating things.
First, here's a solution;
+ X("Snake") < X("Player") + 50
+ X("Snake") > X("Player") - 50
-> Change Animation("Snake") to "StandUp"
+ X("Snake") > X("Player") + 50
-> Change Animation("Snake") to "CrouchDown"
+ X("Snake") < X("Player") - 50
-> Change Animation("Snake") to "CrouchDown"
If you don't make the animations loop back to the first frame, then you don't need any "only one action when event loops" condition.
Now let me try to explain something really rather important...
X("Player") > X("Snake")
-> Change Animation("Snake") to "StandUp"
is NOT the same as
X("Snake") < X("Player")
-> Change Animation("Snake") to "StandUp"
The first example is what you did. It will compare the X coordinates of "Player", and the most recently created instance of "Snake". If "Player" has a greater value of X than the newest "Snake", then ALL "Snake" objects change their animation to "StandUp".
The second example is what you SHOULD have done. It will individually compare the X coordinates of each "Snake" to the the X coordinate of "Player". Only the specific "Snake" objects with a lower value of X will change their animation.
There are a couple of really good articles about this somewhere, but I don't remember what they're called - something to do with "Objct Focus" and "Active & Passive Objects" I think.
Edited by Sketchy
n/a
|
JetpackLover
Registered 01/03/2007
Points 212
|
17th January, 2009 at 15:38:00 -
Sweet it worked!! How come I didn't need to use Spread values for that? And if I wanted to, how could I use spread values for that?
http://www.invincibletime.com/
Devlog for HD MMF Game Omulus. Check it out because it's gonna be awesome. http://omulus.tumblr.com/
Follow me on the twitters https://twitter.com/JetpackLover
|
Sketchy Cornwall UK
Registered 06/11/2004
Points 1971
|
17th January, 2009 at 16:19:41 -
Spread values are simply not appropriate for something like this.
http://www.create-games.com/article.asp?id=1798
Perhaps the most common application of spread values, is combining them with a fastloop. For example;
+ Always
-> Spread "0" in ID#("Object")
+ Always
-> Start loop "MyLoop", NObjects("Object") times
+ On loop("MyLoop")
+ ID#("Object") = LoopIndex("MyLoop")
+ Any other condition you might want to add...
-> Do some action...
This would "Select" each instance of "Object", one at a time, and perform some action on them.
Edited by Sketchy
n/a
|
JetpackLover
Registered 01/03/2007
Points 212
|
18th January, 2009 at 03:47:38 -
Thanks Sketchy you really helped me out!! I just want to thank you for always coming to my aid.
http://www.invincibletime.com/
Devlog for HD MMF Game Omulus. Check it out because it's gonna be awesome. http://omulus.tumblr.com/
Follow me on the twitters https://twitter.com/JetpackLover
|
|
|