User Tag List

Results 1 to 4 of 4

Thread: Slopes varying movement speed?

  1. #1
    No Products Registered

    Join Date
    Jun 2007
    Posts
    323
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Slopes varying movement speed?

    (In a platformer, using the PMO) How can I get my players speed to vary depending on the slope its walking on?

    ie. player is slower when walking up a slope, and faster when walking down.

    I've tried using detectors and additional X velocity for this, but I'm not really sure where to place the detectors and what conditions to use without getting a few quirks. Could someone atleast point me in the right direction? Thanks!

  2. #2
    No Products Registered

    Join Date
    Jul 2006
    Posts
    492
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Slopes varying movement speed?

    You will need two detectors to approximate the angle of the slope. Place them about 5px either side of the player (X position). The best thing to use for this would be the move safely 2 object IMO.

    Set the Y positions of the detector to around 10 pixels higher than the player's feet (this will allow for a maximum gradient of 2:1 giving you plenty of headroom). Now using the MS2 object move both detectors to 10px below the players feet, stopping on collision with an obstacle. So the detectors will both drop down, hit the floor and stop, all instantaneously.

    Now work out the angle between the two detectors using Advanced direction object or a custom mathematical expression.

    I'm pretty sure that just giving additional X velocity would be a poor way to do this, since it would most likely results in the player "bouncing" down steep slopes.

    The following method is not really physically accurate, but should give a satisfactory and tuneable result for a game:

    Use the following:

    Xvel = Xvel + abs(sin(angle))*A*cos(angle)
    Yvel = Yvel + abs(sin(angle))*A*sin(angle)

    Where A is a constant for tuning the magnitude of the effect. These actions will accelerate the player in the direction of the slope depending on the steepness of the slope.

    Also, you probably don't want your character slowly sliding across the level if there is only a gradual incline. So use the following condition the above actions:

    -If player has movement button pressed
    OR
    -If abs(sin(angle))>slip_threshold

    Where slip_threshold is a value at which the character will start sliding down the slope. You should probably set it to around 0.5 (slope of 45 degrees).

    The slip threshold should be tuned alongside the value of A so that the player can always walk up a slope if they don't slip down it at a standstill.

    I hope you understoon all of that :-)

  3. #3
    No Products Registered

    Join Date
    Jun 2007
    Posts
    323
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Slopes varying movement speed?

    Hmm..I understand what your saying with the expressions and slipping, but the detector part isn't making any sense, I've never used MS2 to actually move objects, but just to keep them out of walls.

    Set the detectors at X 5,-5, ok thats easy, but the next part confuses me. Set the Y to -10,-10 of the player, but then 10,10 with the MS2? All I can think of for this is:

    -Always set detectors to -10,10 to player base.

    -Start of frame: Add detectors to protection, prepare safety
    -On safety: Set detectors to 10,10 player base

    But all that does is keep the detectors at -10,-10.

    Could you be a bit more specific on the MS2 code?

  4. #4
    No Products Registered

    Join Date
    Jul 2006
    Posts
    492
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Slopes varying movement speed?

    Nah thats not how you use MS2. You should read the MS2 documentation and study the examples. They will explain it better than I could.

Similar Threads

  1. Slopes in Custom Platform Movement
    By xIronGolemx in forum Multimedia Fusion 2 - Technical Support
    Replies: 10
    Last Post: 15th July 2013, 05:03 PM
  2. Jump through slopes (Platform movement object)
    By MayorJon in forum File Archive
    Replies: 3
    Last Post: 12th December 2011, 12:51 AM
  3. Slopes in Custom Platform Movement
    By Bugsey in forum The Games Factory 2 - Technical Support
    Replies: 3
    Last Post: 16th January 2008, 08:43 PM
  4. Slopes for custom made platform movement
    By Langol in forum Multimedia Fusion 2 - Technical Support
    Replies: 2
    Last Post: 26th September 2007, 05:53 PM
  5. Custom platform movement with slopes
    By DavidN in forum File Archive
    Replies: 13
    Last Post: 4th September 2007, 12:24 AM

Posting Permissions

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