question about dt (when not to?)

Get help using Construct 2

Post » Wed Aug 13, 2014 6:03 am

I understand that C2 behaviors automatically use dt

so if I'm using a behavior to set something, say
every tick
set sprite1.bullet.angleofmotion to sprite2.angle
do I use dt?

and while I'm at it, what about something like this:
rotate sprite1 (sprite2.car.speed/200) degrees toward (sprite2.x, sprite2.y)?

As I'm looking at this, I'm thinking yes, but I could use a little clarification.

EDIT: upon trying some of this out, some of it just doesn't look right.
I think what I really need to know is when NOT to use dt?
B
88
S
43
G
71
Posts: 601
Reputation: 43,669

Post » Wed Aug 13, 2014 12:23 pm

See Delta-time and framerate independence.

You don't need dt if you're just copying values, like setting one object's angle to another object's angle. You only need it when you increment frame-by-frame, such as moving an object to the right every frame, or rotating it a certain amount every frame. This includes rotating towards something: if you rotate 1 degree every frame, that will be 30 degrees/sec at 30 FPS and 60 degrees/sec at 60 FPS, which is framerate dependent; rotating by 60 * dt degrees will always be 60 degrees/sec at any framerate.
Scirra Founder
B
400
S
236
G
89
Posts: 24,546
Reputation: 195,461

Post » Thu Aug 14, 2014 1:13 am

Thank you @Ashley I had read that tutorial and had just gotten to where I had confused myself.

I finally sort of understood it, and the way you just explained nails it down for me.
Thanks!
B
88
S
43
G
71
Posts: 601
Reputation: 43,669


Return to How do I....?

Who is online

Users browsing this forum: tarek2 and 17 guests