Different dt to move objects at the same speed?

0 favourites
  • 8 posts
From the Asset Store
Adjusting the game screen for different resolutions (Letterbox scale)
  • This is a multi-part question...please bear with me.

    .CAPX: https://www.sugarsync.com/pf/D6025908_4317202_6541819

    QUESTION ONE:

    In the .capx event sheet, scroll down to the Mr Stick - Grapple group.

    Starting at line 18...

    • LINE 18: Object GrappleStaple moves forward at dt*200 pixels
    • LINE 19: Every tick, add dt*400 GrappleStapleChainPixelCount (abbv to GSCPCount...hey, it's how I keep track of what the variables are for! LOL)
    • LINE 20: 1) When GSCPCount reaches at least 10, create a new instance of the GrappleStapleChain sprite object at the proper angle, 2) reset the GSCPCount variable
    • LINE 21: As long as the number of instances of the GrappleStapChain object is more than zero, move the instances forward by dt*1000.

    This is what confuses me...

    While the Staple object is moving forward at 200 pixels/second...

    ...a count of 10 per 400/second goes by (I can adjust the "10" value to whatever I want...that'll simply change how often a new Chain sprite object instance is created)...

    ...but I must have the Chain sprite objects moving at a see of 1000 pixels/second to have them move at the same (or CLOSE TO IT) speed of the Staple object.

    If I set the speed of the Chain objects to the same value as in line 18, the Chain objects would seem to trail behind, creating a huge gap between the Chain links and the Staple. Even trying to account for the average 60 ticks/second runtime, this isn't making any sense. Why can't the speed of the Chain and the Staple be the same value in the event sheet?

    QUESTION TWO:

    You'll notice on line 22, once the Staple object overlaps with the platformSquareBox object, it's supposed to stop the Staple object from moving - I set the movement to zero pixels per second. Back at line 18, one of the two conditions are so long as the Staple object is NOT overlapping with the box may it continue moving. But even after testing that C2 is registering that there is an overlap, which would make line 18 false, the Staple object continues to move forward. What gives? This includes the fact that once there is an overlap the GrappleFire variable is set to "NoFire", which also should prevent the Staple movement. I did have this working just the other day (thanks much to ramones).

    Thank you for your help!

  • I think you are possibly over-complicating this. Have you considered using physics and revolute joints on your grapple and grapple chain?

    With help from ramones I built this "dynamic" rope creator where I work out the segments I need and chain them together using joints (Hold mouse to start a bridge, release on a diff block to build the bridge), I can see a similar thing working for your grapple.

    dl.dropbox.com/u/116137178/GamesDev/Bridge3/Bridge3.capx

    Just make sure you remember to turn collisions off between staple and chain objects. :)

  • 1. The GrappleStaple has bullet behavior with speed 800 and you're moving it forward manually by 200*dt per tick. 800 + 200 = 1000.

    2. Related problem - when you hit the box you stop moving it forward by 200*dt but the bullet behavior keeps going.

  • ramones - *FACEPALM* I thought I had either deleted that behavior or simply by not USING it in the event sheet it wouldn't be in effect. It's those "little things" that I am not yet aware of that always seem to get me. You're certainly getting major kudos in my end-of-game credits (I'm making a list and checking it twice LOL). As always, I'm very grateful for your help. God bless you, truly!

    ...*a moment later*... SUCCESS! That did the trick and it looks just like I hoped! :D

    silkc2 - You're talking about stuff I'm not yet familiar with (lol), but I'll definitely check out your example and see if I can't employ it later. Thank you for your suggestion. :)

  • silkc2 - Whooooaaaaa! THAT is way cool. Gonna take me a moment to wrap my head around what's all going on in the event sheet, but that's VERY sweet lookin'! Good job!

  • Physics are fun.. :D

    It isn't too hard, the main difficulty I had was getting my head around the quirks of c2 itself and how it behaves with newly created objects.

    See for your grapple I was thinking apply a solid physics push to the staple to send it flying with all the physics worked out for you, and the chains linked to it (dynamically created), also using physics (but not collisions).

    It's just theory crafting, I haven't done a grapple mechanism myself.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • More of a question to silkc2, since I ran into a problem that he solved with families.

    I wanted to set Physics joints between instances of sprites at run-time (and dynamically alter those joint connections), and it appears there is no way to select the sprite instance target, except by the technique of using families, which I do not have access to in the free version. Is that correct?

    Thanks.

  • Sorry for the late reply - yes, you can only access two different instances of the same sprite at the same time via families, i.e. paid c2.

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