User Tag List

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

Thread: 8-direction NPC destination setting

  1. #1
    No Products Registered

    Join Date
    May 2016
    Posts
    17
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Exclamation 8-direction NPC destination setting

    Hello there.

    I've been tearing my hair out for a couple of weeks trying to get this working, but I just can't seem to wrap my head around it.

    Basically, I have NPC's in a top-down grid-based environment, but the movement is true 8-direction so it doesn't snap to the grid. The grid itself is 48x48 pixels per square. I have the following variables for each NPC:

    MoveX - Determine the distance to move and in which direction. 1=right and -1=left
    MoveY - 1=down, -1=up
    DestX - X-Coordinate of desired destination
    DestY - Y-Coord
    StartX - The starting coords of the NPC
    StartY

    Then I have the following conditions and actions which deal with the movement (this is for X only, Y is seperate)

    Every 00"-01
    O_NPC:Set X Position to X("O_NPC") + MoveX("O_NPC")

    #Stop moving if reached destination
    X Position of O_NPC = DestX("O_NPC")
    O_NPC:Set MoveX to 0
    O_NPC:Set DestX to -1

    #If destination set the move in correct direction
    DestX of O_NPC > X("O_NPC")
    O_NPC:Set MoveX to 1

    DestX of O_NPC < X("O_NPC")
    DestX of O_NPC >=0
    O_NPC:Set MoveX to -1

    #Stop moving if no destination
    DestX of O_NPC = -1
    O_NPC:Set MoveX to 0



    Now this logic seems to work perfectly when there is only one NPC on the screen. However I run the following calculation on the DestX and DestY values every random amount of time for each O_NPC on the board.

    O_NPCestX = StartX( "O_NPC" ) + ( 48 * (Random(3)-1) )

    This calculation would mean the NPC's can never travel more then 1 cell away from their original start location. Now if you introduce two NPC's on to the board, the new NPC will operate normally but the first NPC occasionally acts erratic, goes farther away from the start point than it should, and even just keep going without stopping. It seems somewhere that logic which should only apply to one NPC, seems to apply to more than one. If I add 6 NPC's to the board, most of them go haywire and start drifting farther away from their start locations than they should.

    If anyone can help me with this you will save me from having to top myself after going mad trying to solve the problem.

    Alternatively, if you could offer a better solution for both creating 8-direction movement for NPC's and creating destination coords while keeping each NPC a seperate entity.

    Also my apologies if I haven't typed out the logic in a format that's understood. Am new to these forums and haven't learned the lingo yet :P

  2. #2
    No Products Registered

    Join Date
    May 2016
    Posts
    17
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Also, just to add. I was using the Safety 2 Move object after reading through previous posts on here, but using the method I found (which is similar to the one above, only without the destination coords and prepare safety etc. included) but I found that when two NPC's collided with an object, the game would crash.

  3. #3
    No Products Registered

    Join Date
    May 2016
    Posts
    17
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ok, well to ask a favour then does anybody have an example of independant 8-way movement for NPC's that I can have a look at so I can get the general idea since I seem to be missing something?

    I've been assessing MMF on my friends laptop to determine if it is what I need to start work on my new game. I'll be honest, I am very impressed with it so far. If I can lick this movement stuff as well then I will definitely be going in for the developer version.

  4. #4
    Clicker Fusion 2.5 DeveloperHTML5 Export ModuleiOS Export ModuleUnicode Add-onInstall Creator Pro
    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)

    Join Date
    Jul 2006
    Posts
    574
    Mentioned
    9 Post(s)
    Tagged
    0 Thread(s)
    Are you able to provide an example file? There's probably a generalized event which is altering the values.

  5. #5
    No Products Registered

    Join Date
    May 2016
    Posts
    17
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I have attached the mfa I am currently working on. You won't be able to run it however as it relies on external files that are created by a different program.

    map.mfw

    The NPC movement is contained with the object O_Zombie and the random NPC movement is contained in the global events list under the groups NPC->Movement->Random

  6. #6
    Clicker Fusion 2.5 DeveloperHTML5 Export ModuleiOS Export ModuleUnicode Add-onInstall Creator Pro
    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)

    Join Date
    Jul 2006
    Posts
    574
    Mentioned
    9 Post(s)
    Tagged
    0 Thread(s)
    it wont open. missing sprites.mfa

  7. #7
    No Products Registered

    Join Date
    May 2016
    Posts
    17
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Sorry, try this stripped down version

    Game.mfa

  8. #8
    No Products Registered

    Join Date
    May 2016
    Posts
    17
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Can nobody please help me out? I'm only trying to build my own 8-way movement because everybody on the forums say the collision detection of the built-in one is terrible.

  9. #9
    Forum Moderator

    Fusion 2.5 MacFusion 2.5 DeveloperFusion 2.5+ DLCAndroid Export ModuleHTML5 Export ModuleiOS Export ModuleMac Export ModuleUniversal Windows Platform Export ModuleSWF Export ModuleInstall Creator Pro
    Fusion 2.5 (Steam)Fusion 2.5 Developer (Steam)Android Export Module (Steam)HTML5 Export Module (Steam)iOS Export Module (Steam)

    Join Date
    Dec 2013
    Location
    Watertown, WI
    Posts
    4,421
    Mentioned
    60 Post(s)
    Tagged
    0 Thread(s)
    Tried looking at the file.. All I get is a white screen.
    Not sure what you mean with "everybody on the forum".
    I have no problems with collision detection what so ever. Did you try the built-in one?

  10. #10
    No Products Registered

    Join Date
    May 2016
    Posts
    17
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I've no idea how to export a file then. But yes, I did try the built in one, but the result was the same. It seems to be a problem with conditions for one object being applied to all objects. I'm using Groups.NPC as the object for the conditions.

    The main problem in the logic I can see is that certain objects continue to move even though the condition states that MoveX should be 0. When I check the current value of both MoveX and MoveY it is not zero, hence why it keeps moving.

Page 1 of 2 1 2 LastLast

Similar Threads

  1. Replies: 0
    Last Post: 25th May 2016, 10:40 AM
  2. Destination: JAR
    By Gimbabwe in forum Multimedia Fusion 2 - Technical Support
    Replies: 4
    Last Post: 14th September 2011, 11:13 PM
  3. Destination Folder From Registry
    By Khorrami in forum Install Creator and Patch Maker
    Replies: 3
    Last Post: 10th December 2010, 12:16 PM
  4. One file two destination, is that possible?
    By Ran_TH in forum Install Creator and Patch Maker
    Replies: 2
    Last Post: 5th July 2009, 09:12 AM
  5. setting an objects direction in 360 degrees
    By mobichan in forum Multimedia Fusion 2 - Technical Support
    Replies: 17
    Last Post: 24th April 2008, 05:43 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
  •