Lock object on image point

Get help using Construct 2

Post » Thu Dec 11, 2014 2:00 am

Had to start another thread since my turret arm system keeps giving me problems. I'm trying to create a system where the player's arm is seperate from rest of the body. I made an event where the arm sets its position to the body's image point 1 at every tick, but somehow the arm keeps lagging behind as if I added a lerp effect to it. I've checked many times that I hadn't done any lerping to its position, so I don't know why the arm keeps lagging.

Basically all I'm doing is using a condition "every tick" and an event "Set position to Player_Sprite image point 1"

I'm sorry if this is confusing. My project is rather large and full of holes currently so I can't really share it with you guys.
B
21
S
7
G
4
Posts: 233
Reputation: 3,474

Post » Thu Dec 11, 2014 4:34 am

Can't do much more than throw guesses at ya with only this much info to go on.

Is the sprite and/or the arm animated? if so, are the image points changing with the animations?

How's your framerate? Could it just be lag?

Why not use pin behavior?
B
88
S
43
G
71
Posts: 601
Reputation: 43,669

Post » Thu Dec 11, 2014 4:02 pm

The image point does move on every frame on running/jumping animations etc. The arm is not animated except when firing, but its own origin does not move. This should not cause lag like that. Framerate is a constant smooth 60 FPS. Can I pin objects to image points? I need to pin it to image points and not the origin point because otherwise the arm would look floaty and seperate from the character.
B
21
S
7
G
4
Posts: 233
Reputation: 3,474

Post » Thu Dec 11, 2014 6:39 pm

have you tried it without the image point moving every frame? that might have something to do with it. you can pin it in the position of the image point, but not actually to the image point (I think), so it won't follow a changing image point. Really can't help much without seeing it firsthand.. Maybe open a separate project with the minimal pieces and see if you can pinpoint the problem and if not, share with us the new project capx and we'll do our best!
B
88
S
43
G
71
Posts: 601
Reputation: 43,669

Post » Thu Dec 11, 2014 7:01 pm

Perhaps you're positioning the arm before the events that move the body. You should put your events that position the arm after the events that move the body. If the events that move the body are after the arm events, then it will look like it is lagging because the arm would be positioning itself to the previous body position and not the current position.
B
47
S
22
G
65
Posts: 1,127
Reputation: 38,395

Post » Thu Dec 11, 2014 10:07 pm

spacedoubt wrote:have you tried it without the image point moving every frame? that might have something to do with it. you can pin it in the position of the image point, but not actually to the image point (I think), so it won't follow a changing image point. Really can't help much without seeing it firsthand.. Maybe open a separate project with the minimal pieces and see if you can pinpoint the problem and if not, share with us the new project capx and we'll do our best!


I did remake the system on a blank file and the problem was solved. It must has to have something to do with the turret's constant changing of angle. The gun turns to face the direction you move into, so it's constantly rotating with a lerp effect. I've tried disabling as many conditions as possible but the problem just won't go away. I'll play around more today. Maybe there's something very obvious I'm just missing.

Prominent wrote:Perhaps you're positioning the arm before the events that move the body. You should put your events that position the arm after the events that move the body. If the events that move the body are after the arm events, then it will look like it is lagging because the arm would be positioning itself to the previous body position and not the current position.


I've tried putting the event to the very top and bottom of the event sheet but it's not changing.

This is just so weird because the arm keeps lagging behind and looks like I've added some kind of lerping to it even if I haven't. Setting the object's position on every tic should logically make it work, but there's something more technical going on that's causing this.
B
21
S
7
G
4
Posts: 233
Reputation: 3,474

Post » Thu Dec 11, 2014 10:34 pm

Alright, double post, but I think I found a bug in the system. I recreated the player objects from my project into a blank project once again and this time the same problem arise. In my problem the player is built from a hitbox with platform controls, player's sprite on top of and pinned to that hitbox and then the gun set to the sprite's image point. This somehow causes the gun to lag. If I set it to the actual hitbox's image point there won't be any problems.

I might be explaining things in a bit confusing way, so check the project out for yourself: https://dl.dropboxusercontent.com/u/505 ... tlock.capx

Does this seem like an oversight from the devs? Or is there something I'm doing wrong? If someone feels like fixing this, keep in mind that setting the arm object to the blue object is vital. I can't set it to the red box and make it look good with the player's animations. That's just how my game is built.
B
21
S
7
G
4
Posts: 233
Reputation: 3,474

Post » Thu Dec 11, 2014 11:03 pm

If you disable the pin and set Sprite2 position and then Sprite3 position it's fixed. I would guess Pin sets the position after the events so it lags one tick behind. I think this was what Prominent meant.
B
34
S
9
G
3
Posts: 517
Reputation: 5,246

Post » Thu Dec 11, 2014 11:23 pm

Aha! That did the trick! And here I was thinking that I've found a serious bug in the system. Great, now I can get back to devving without having to watch a floaty rubber arm dangling behind my character :)
B
21
S
7
G
4
Posts: 233
Reputation: 3,474

Post » Sat Jan 31, 2015 8:06 pm

Katala wrote:If you disable the pin and set Sprite2 position and then Sprite3 position it's fixed. I would guess Pin sets the position after the events so it lags one tick behind. I think this was what Prominent meant.


You sir, you are awesome. Thank you soooooo much! :D
B
8
S
2
Posts: 6
Reputation: 518

Next

Return to How do I....?

Who is online

Users browsing this forum: CreativeMind and 25 guests