How do I make a Pullback Mechanism

  • Hi all,

    I been working on an idea for a while now, but I'm only half satisfied with the way it controls so figured I should swallow my pride and ask the mother-brain for help.

    Essentially, it's a kind of pullback toy car. Here's the bare bones of it. https://www.dropbox.com/s/5rkgpjwx2tc2wu3/Pullback%20Test.capx?dl=0 Just drag the car back and release it.

    It borrows heavily from the examples of how to make an Angry Birds style catapult, but with Zero world gravity to make it top down, and dampening on the car to make it a bit more realistic (a bit). In hindsight this may not be the best way to approach this but couldn't think of anything better. The main issue I'm having is how to stop the car being moved through walls while it's being pulled back.

    Would I perhaps be better using Drag and Drop behavior to pullback the car? If so how would I make that affect the physics impulse AND be able to stop it when its dragged into a wall? There are no real hard and fast rules here, except that the car must have Physics behavior and it's propulsion speed upon release must be based on how much it has been pulled back.

    Any ideas, suggestions or feedback would be greatly appreciated.

    PS: The cute car asset is from here http://www.kenney.nl/assets/racing-pack

  • Make an invisible sprite the size of the car (or a bit bigger for better touch control).

    Add Drag & drop behavior to this sprite. When the sprite Is Dragging, set the car to sprite position, but only if the sprite is not overlapping walls.

    You can pin two invisible sprites together - a bigger one for dragging and a smaller for overlapping checks.

    Also I think you should disable Physics on the car while it's being pulled. Re-enable it when it's released.

  • Great, thanks dop2000 that sounds like a plan. I'll give it a go

  • Ok tried a few things out, and while it is better, it's still less than ideal

    https://www.dropbox.com/s/eq5fmyb4vy4pnxn/Pullback%20Test%202.capx?dl=0

    I've had to have the car snap back to the origin position when it's pulled back into a wall. I'd rather it stayed in the position touching the wall, but I can't find a good way to do this while still keeping the pullback action active

    On some occasions the Car Sprite gets stuck in the wall entirely and you're unable to pull it out

    All in all it is an improvement. It could be much better though, so still open to suggestions, input, opinions, general hearsay and rumors

  • I fixed it <img src="{SMILIES_PATH}/icon_e_smile.gif" alt=":)" title="Smile">

    https://www.dropbox.com/s/34dycek87zrwi ... .capx?dl=0

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Wow that's great. So quick too. Any ideas how to constrain the drag & drop so we can only pull the car back a small amount like in the original? it's quite important that the player can't pull the car back indefinitely. Sure I'll figure something out with some tinkering though

    This is way better though and easier to work with Thank you dop2000

  • Christmas

    Ok, an improved version, should work as you described:

    https://www.dropbox.com/s/0ctlui86sbd4l ... .capx?dl=0

  • Yeah you know what dop2000 I think that may be perfect

    I had a go at breaking it, but other than the dragging outside layout thing, which isn't going to be an issue, there doesn't seem to be any problems with this at all. I love it

    I owe you one

  • No worries!

    I just realized that the blue CarCollision sprite is not necessary in the last example. You can replace it with Car in all events, then delete.

  • *Replaces and deletes whilst humming 'Here in my Car' by Gary Numan*

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