User Tag List

Page 1 of 2 1 2 LastLast
Results 1 to 10 of 14

Thread: Total n00b enemy movement question, but I can't get this to work

  1. #1
    Clicker Fusion 2.5
    Del_Duio's Avatar
    Join Date
    Sep 2008
    Location
    Cygnus X-I
    Posts
    985
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    Total n00b enemy movement question, but I can't get this to work

    Oh how embarrassing, but programming is not my strong suit..

    I'm trying to make a simple mini game, however it's not working out too well when it comes to the enemy movements. Each enemy is a 16 x 16 square with the ball movement in the 4 main directions N/S/E/W. Each enemy has the 'Enemy' qualifier to it, and I'm using alt variable A to keep track of what direction the thing's supposed to be moving in (where 0= west, 1 = east, 2 = north, 3 = south).

    Then there's an event where if group.enemy overlaps a backdrop it changes alt variable A to random (4), which should change his direction and get him moving away from the wall (in most cases, of course if that random #'s = the direction he's already going in he'd have to change his direction on a subsequent pass through the code but that's OK).

    But it's not working 100% of the time. Sometimes the monster will rebound off the wall which is good. Sometimes he'll just walk right through walls and off the frame. Sometimes he'll rebound off a wall but then fail a secondary wall check and walk right through that one. I wanted to keep the overall enemy code pretty simple as far as them just moving randomly in 4 directions and changing those directions if they strike a wall. I mean this should be really easy to do, right?

    Any ideas and thanks!

  2. #2
    Clicker Fusion 2.5 DeveloperAndroid Export ModuleiOS Export ModuleSWF Export Module
    Fusion 2.5 (Steam)Fusion 2.5 Developer (Steam)Android Export Module (Steam)HTML5 Export Module (Steam)iOS Export Module (Steam)Universal Windows Platform Export Module (Steam)
    Popcorn's Avatar
    Join Date
    Jun 2006
    Location
    Norway, Bergen
    Posts
    2,373
    Mentioned
    13 Post(s)
    Tagged
    0 Thread(s)
    While your approach seems smart at first, it can quickly be complicated when you have to make sure the object only goes in the direction availible for it.
    Here's another approach you can use that is extremely simple and should work as you intend to:

    * Group.Enemies collides with Background
    - Group.Enemies: Bounce
    - Group.Enemies: Set Direction to all directions (select all arrows in the direction selector, or only the 4 main ones, it doesn't matter)

    * Always
    - Group.Enemies: Set Direction to Dir( "Group.Enemies" ) / 8 * 8

    The last event will force the object to go to the main direction closest to its current direction.

  3. #3
    Clicker Fusion 2.5
    Del_Duio's Avatar
    Join Date
    Sep 2008
    Location
    Cygnus X-I
    Posts
    985
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Brilliant, Popcorn!

    Thanks a lot, I'll give this a try and let you know if it works

  4. #4
    Clicker Fusion 2.5
    Del_Duio's Avatar
    Join Date
    Sep 2008
    Location
    Cygnus X-I
    Posts
    985
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    It works like a charm!
    I mean EXACTLY how I wanted it to work, awesome!

    Thanks again!

  5. #5
    Clicker Fusion 2.5 DeveloperAndroid Export ModuleiOS Export ModuleSWF Export Module
    Fusion 2.5 (Steam)Fusion 2.5 Developer (Steam)Android Export Module (Steam)HTML5 Export Module (Steam)iOS Export Module (Steam)Universal Windows Platform Export Module (Steam)
    Popcorn's Avatar
    Join Date
    Jun 2006
    Location
    Norway, Bergen
    Posts
    2,373
    Mentioned
    13 Post(s)
    Tagged
    0 Thread(s)
    Great to hear that!
    I actually learned something new here as well, i have struggled with the same thing before, and then i didn't think about this approach

  6. #6
    Clicker Fusion 2.5Android Export ModuleSWF Export Module
    Ziplock's Avatar
    Join Date
    Oct 2013
    Posts
    448
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Why are you setting the direction to ALL then to dir/8*8? Why don't you just set it to the 4 directions and be done with it? (No rudeness implied, I'm just trying to understand the difference.)

  7. #7
    Clicker Fusion 2.5 DeveloperAndroid Export ModuleiOS Export ModuleSWF Export Module
    Fusion 2.5 (Steam)Fusion 2.5 Developer (Steam)Android Export Module (Steam)HTML5 Export Module (Steam)iOS Export Module (Steam)Universal Windows Platform Export Module (Steam)
    Popcorn's Avatar
    Join Date
    Jun 2006
    Location
    Norway, Bergen
    Posts
    2,373
    Mentioned
    13 Post(s)
    Tagged
    0 Thread(s)
    if you don't do the 8/8 calculation, the movement will be flawed. Test it yourself and see.

  8. #8
    Clicker Fusion 2.5Android Export ModuleSWF Export Module
    Ziplock's Avatar
    Join Date
    Oct 2013
    Posts
    448
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Honestly, I did. They both perform the same way - at least for a single object.

    If you use the /8*8 calculation, you get the results 0,8,16,and 24, no? The same as if you set just the 4 directions.

  9. #9
    Clicker Fusion 2.5 DeveloperAndroid Export ModuleiOS Export ModuleSWF Export Module
    Fusion 2.5 (Steam)Fusion 2.5 Developer (Steam)Android Export Module (Steam)HTML5 Export Module (Steam)iOS Export Module (Steam)Universal Windows Platform Export Module (Steam)
    Popcorn's Avatar
    Join Date
    Jun 2006
    Location
    Norway, Bergen
    Posts
    2,373
    Mentioned
    13 Post(s)
    Tagged
    0 Thread(s)
    Yes, but I run that calculation ALWAYS. I experienced that when we just set it to bounce and set it to 4 directions, sometimes it would still choose another direction. So the ALWAYS event correct any misdirection the object will get.

  10. #10
    Clicker Fusion 2.5Android Export ModuleSWF Export Module
    Ziplock's Avatar
    Join Date
    Oct 2013
    Posts
    448
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You are very correct. I had to let it run for a while, but it did eventually go in another direction. That's quite the bug. If I tell it to go in directions 0,8,16,or24, why would it just decide to go in direction 17?

Page 1 of 2 1 2 LastLast

Similar Threads

  1. Wicked n00b question concerning developing for XBOX Live
    By Del_Duio in forum Multimedia Fusion 2 - Technical Support
    Replies: 2
    Last Post: 23rd October 2013, 02:16 PM
  2. Total hours difference between two dates (timeStamp does not work)
    By Blizna in forum Multimedia Fusion 2 - Technical Support
    Replies: 1
    Last Post: 11th June 2013, 11:28 PM
  3. Total number of Global Alterable Values question
    By mobichan in forum Multimedia Fusion 2 - Technical Support
    Replies: 7
    Last Post: 16th May 2012, 11:08 PM
  4. Total movement speed
    By King_Cool in forum Multimedia Fusion 2 - Technical Support
    Replies: 3
    Last Post: 25th March 2012, 10:36 PM
  5. n00b Question on Random Events
    By DRaux007 in forum Multimedia Fusion 2 - Technical Support
    Replies: 6
    Last Post: 13th April 2008, 08:11 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •