Different dt to move objects at the same speed?

Get help using Construct 2

Post » Tue Mar 05, 2013 8:35 am

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'm seeking Narnia. Who wants to come with me! Aslan is on the move!
B
112
S
20
G
8
Posts: 741
Reputation: 13,636

Post » Tue Mar 05, 2013 10:06 am

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.

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

Just make sure you remember to turn collisions off between staple and chain objects. :)silkc22013-03-05 10:07:00
B
20
S
6
G
2
Posts: 157
Reputation: 3,109

Post » Tue Mar 05, 2013 6:11 pm

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.
B
54
S
28
G
18
Posts: 1,520
Reputation: 24,990

Post » Tue Mar 05, 2013 8:02 pm

@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. :)
I'm seeking Narnia. Who wants to come with me! Aslan is on the move!
B
112
S
20
G
8
Posts: 741
Reputation: 13,636

Post » Tue Mar 05, 2013 11:20 pm

@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!
I'm seeking Narnia. Who wants to come with me! Aslan is on the move!
B
112
S
20
G
8
Posts: 741
Reputation: 13,636

Post » Tue Mar 05, 2013 11:53 pm

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.
silkc22013-03-05 23:54:58
B
20
S
6
G
2
Posts: 157
Reputation: 3,109

Post » Wed Mar 06, 2013 12:41 am

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.
B
14
S
4
G
1
Posts: 26
Reputation: 1,747

Post » Mon Mar 11, 2013 12:02 pm

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.
B
20
S
6
G
2
Posts: 157
Reputation: 3,109


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 26 guests