Image points and positioning on moving objects

Get help using Construct 2

Post » Thu Feb 19, 2015 2:22 pm

What Im trying to do is quite simple, a drag&drop type arrow that extends from the origin point to the "touch" point.

Im using two sprites for this:

A simple rectangle for the "body" of the arrow which width I'll be adapting on real time (Width = distance(Self.X, Self.Y, Touch.X, Touch.Y) ). Its center is on the left end of the sprite, and it has another image point on the right end for the next sprite.

A triangle shape for the tip of the arrow (The arrow tip uses his own sprite because I dont want the tip to get deformed with the changing of width, obviously)

The body of the arrow is pinned (position only, not angle, since the angle would be angle(Self.X, Self.Y, Touch.X, Touch.Y) ) to where I want it to origin, and the tip of the arrow is replaced at every tick at the corresponding image point with the corresponding angle.

And well, it works. The problem? When the origin of the arrow is a behavior-based moving object.

In my example, you can make the arrow appear holding left click, and it looks ok, the problem comes when at the same time you move around the origin (standard 8Direction behavior, use the cursor keys), specially if you are moving away from the arrow.

As you can see, the arrow tip gets misplaced, not by much, but enough to break the arrow shape

Am I doing something wrong? Any workaround for this?

DEMO
CAPX
B
19
S
5
Posts: 46
Reputation: 1,141

Post » Fri Feb 20, 2015 3:42 am

the rectangle looks to be a sprite. Have you changed it to a tiled background and seen any difference?
B
9
S
2
Posts: 80
Reputation: 854

Post » Fri Feb 20, 2015 5:49 am

In my experience, the Pin behavior has trouble keeping pace with moving objects.
B
11
S
4
Posts: 152
Reputation: 1,236

Post » Fri Feb 20, 2015 6:04 am

I suspect the *reason* the pin behavior doesn't keep up well is the sort of behavior you see if you remove the pin and add "arrow -> Set Position to player" right before "arrow_tip -> Set Position to arrow"

I... don't have a workaround or solution. :\
B
11
S
4
Posts: 152
Reputation: 1,236

Post » Fri Feb 20, 2015 12:56 pm

I solved it! :D (Well, kinda)

I just prescinded of using the pin behaviour to bind the rectangle to the player object, and did it manually (as I was already doing with the arrow tip)

By the way, first way I tried to do this was by also pinning the arrow tip to the end of the rectangle, but apparently, pin behavior doesnt take into account size changes (at least with width variations) so the arrow tip was stuck at the begining of the arrow no matter the actual width of the arrow body...I dont know if this is expected or if it may be a pin behavior bug.

With doing everything manually the arrow shape is perfectly consistent, although this 1-frame lag the arrow tip was suffering is now present at the point where the arrow comes out from the player object.

Not perfect, I know, but its actually barely noticeable. Specially if compared to the botched arrow shape from before.

In any case, thank you guys!
B
19
S
5
Posts: 46
Reputation: 1,141


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 0 guests