How do I keep a player "on rails"?

0 favourites
From the Asset Store
Players follower. use it for anything which follows the player
  • Good advice, I'll give that a shot. Thanks again for all your help!

  • Here's the example tweaked to work with rotated ellipses.

    For unrotated ellipses dx and dy are just (Sprite2.x-sprite.x) and (sprite2.y-sprite.y).

    https://dl.dropboxusercontent.com/u/542 ... lipse.capx

  • Here's the example tweaked to work with rotated ellipses.

    For unrotated ellipses dx and dy are just (Sprite2.x-sprite.x) and (sprite2.y-sprite.y).

    https://dl.dropboxusercontent.com/u/542 ... lipse.capx

    Nice one, haha..

  • Here's the example tweaked to work with rotated ellipses.

    For unrotated ellipses dx and dy are just (Sprite2.x-sprite.x) and (sprite2.y-sprite.y).

    Hey, that's awesome! I was just trying to figure out how to get the center area of my pill shaped track to work (and failing), so this example is a nice surprise.

    The only issue is that it doesn't allow for multiple players to move independently (or at all, it seems) like LittleStain's example. How would I go about setting that up here?

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Sorry, I think I neglected the fix in LittleStain's capx. I don't use multi-touch devices so I didn't test. The fix is to do what LittleStain did in his capx.

    1st add this event:

    on touched sprite2
    --- sprite2: set touchID to touch.touchID[/code:36jgbpqk]
    
    2nd replace sprite2.x and sprite2.y with
    touch.XForID(Sprite2.TouchID)
    and
    touch.YForID(Sprite2.TouchID)
    
    That should make it behave like LittleStain's capx.
  • Sorry, I think I neglected the fix in LittleStain's capx. I don't use multi-touch devices so I didn't test. The fix is to do what LittleStain did in his capx.

    1st add this event:

    on touched sprite2
    --- sprite2: set touchID to touch.touchID[/code:1wje2lv4]
    
    2nd replace sprite2.x and sprite2.y with
    touch.XForID(Sprite2.TouchID)
    and
    touch.YForID(Sprite2.TouchID)
    
    That should make it behave like LittleStain's capx.
    

    I made those changes but nothing seems to have changed. Does this look correct?

  • Yeah that's the changes as I described. Can't see what's amiss. I'm unable to test. :/

    Ok, the general idea for multi touch is each new finger press has an id.

    When you touch a sprite2 the current is saved in a variable so you know which sprite2 goes to what finger.

    The code above is supposed to loop over each sprite2 and basically move to the closest point on the circle near that sprite2's assigned finger.

    But if it doesn't work then I'm kind of stumped until I do some testing on a multi-touch device.

  • Looks to me like it should work..

    Only thing I did different was resetting the Sprite2.touchID to 0 on drag and drop drop.

    R0J0hound

    Could it be that the for each statement here messes it up?

  • I don't think the "for each" would be the issue. I'm kind of curious if the "or" us throwing it off when combined with the drag n drop behavior. It shouldn't though. Actually it could be the drag n drop behavior isn't correctly handling multiple objects being dragged at once.

    Until we can prove that one way or another we could get rid of the dragndrop behavior and do it ourselves with events. Like so:

    on sprite2 touched

    --- set id to touch.id

    --- set dragging to true

    dragging is true

    for each sprite2

    --- set position to (touch.XForID(Sprite2.TouchID), touch.YForID(Sprite2.TouchID))

    on any touch end

    pick sprite2 id = touch.id

    --- set dragging to false

  • R0J0hound

    The "for each" doesn't seem to do anything..

    Removing it in the capx you posted changes nothing while "playing"

    Which makes me think removing it in the example with TouchID will make the program work as wanted..

  • Yeah, the For Each doesn't seem to make any functional difference. Still no luck getting simultaneous moving objects, either, which seems odd since it's more or less the same as LittleStain's working one as far as that piece is concerned?

    It's worth noting that I also tried R0J0hound's "no dragdrop" workaround with no change.

  • Instead of using global variables, make ratio, dx, dy and ang instance variables of Sprite2 and all should work..

  • Instead of using global variables, make ratio, dx, dy and ang instance variables of Sprite2 and all should work..

    Good call! Working perfectly now. Thanks for the help, everyone.

  • Is there anyway to I could possibly accomplish the same movement, but with the arrow keys?

  • Is there anyway to I could possibly accomplish the same movement, but with the arrow keys?

    actually there is a tutorial with capx solar system i think, try searching for it, i had the capx long time ago, and it was using arrow keys basically was doing same thing just around some sun

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)