How do I smooth move forward?

Get help using Construct 2

Post » Thu Sep 11, 2014 5:32 pm

Hello World,

So I need to make a smooth following camera, at the moment my game keeps hanging for like a split second once in a while. And I can't use the "scroll to" behavior on my character so I can put lerp on it. I don't remember exactly why I can't use "scroll to", but I do remember that way back when I started working on the game I tried "scroll to" and it didn't work with my other systems.
So right now my scrolling is done with the "move forward" action on every tick. Is there any way I can use lerp with that? Or maybe something else for "move forward" to make it smooth?
Here's how things are set up:
Event: Character is on layer
subevent: every tick; action: PlayerBox move forward 1.3 pixels
subevent: every tick; action:set Character position to PlayerBox(image point 0)
Event: every tick; action: scroll to(PlayerBox.X, 400)

PlayerBox is just an invisible sprite I attached the character and movement to.
B
21
S
11
G
6
Posts: 414
Reputation: 5,335

Post » Thu Sep 11, 2014 7:38 pm

One thing you can do is incorporate dt in the move forward action. The frame time can fluctuate from frame to frame and dt is the current frame time.

So instead of 1.3 use 1.3*60*dt.
B
94
S
33
G
118
Posts: 5,395
Reputation: 75,851

Post » Thu Sep 11, 2014 7:40 pm

every tick is framerate dependant, search for delta time dt and/or framerate independant movement..

also instead of setting the character every tick, why noy pin the character to the playerbox?
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Fri Sep 12, 2014 8:09 pm

I tried using dt like you suggested @R0J0hound and the game doesn't hang anymore, instead now it kinda "skips" back and forth(very fast, both movements in like a split second) where the hangs would be. Suggestions?
@LittleStain I thought I already did that. As you can see from my events the character doesn't move, the invisible playerbox object has the movement on it, while the character just adjusts it's position to the playerbox object every tick. Is that what you are reffering to when you say "pin" or is it something else all togheter?
B
21
S
11
G
6
Posts: 414
Reputation: 5,335

Post » Fri Sep 12, 2014 9:10 pm

With pin I was referring to the pin-behaviour instead of setting position every tick..
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Sat Sep 13, 2014 12:13 am

Ok, I tried the pin behavior @LittleStain, seems to work pretty much the same. Are there any advantages/disadvantages to using the pin behavior instead of what I was doing?
B
21
S
11
G
6
Posts: 414
Reputation: 5,335

Post » Mon Sep 15, 2014 8:52 am

Bump.
B
21
S
11
G
6
Posts: 414
Reputation: 5,335

Post » Mon Sep 15, 2014 9:53 am

Less code in the long run, and easier to implement. Also less chance of 1 sprite going walkabout without the other.
You can also look at containers. Add your playerbox to character.

I also like to have instance variables that store current x,y of moving sprites... has lots of use down the road from undo buttons to savepoints etc.

So many ways to achieve same thing. But the best way is completely dependent on what you want, what are you comfortable with etc etc.
You think you can do these things, but you can't, Nemo!
Just keep reading.
Just keep learning.
B
65
S
16
G
9
Posts: 1,429
Reputation: 12,728

Post » Tue Sep 16, 2014 5:50 pm

I guess that makes sense @Dutoit ty. What about the problem with my game hanging, any more ideas guys?
B
21
S
11
G
6
Posts: 414
Reputation: 5,335

Post » Tue Sep 16, 2014 7:19 pm

VIKINGS wrote:I guess that makes sense @Dutoit ty. What about the problem with my game hanging, any more ideas guys?


Sorry, can't picture it. But are you *dt?
Which scroll to you using? The behaviour or via system. Because the behaviour is the one you want... its just about enabling it. Nothing magic. It just works.
You think you can do these things, but you can't, Nemo!
Just keep reading.
Just keep learning.
B
65
S
16
G
9
Posts: 1,429
Reputation: 12,728

Next

Return to How do I....?

Who is online

Users browsing this forum: EuropaMin3r, maddy467 and 9 guests