Image points and positioning on moving objects

0 favourites
  • 5 posts
From the Asset Store
Connect the dots in the correct order and draw happy animals!
  • 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

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • the rectangle looks to be a sprite. Have you changed it to a tiled background and seen any difference?

  • In my experience, the Pin behavior has trouble keeping pace with moving objects.

  • 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. :\</p>

  • I solved it! (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!

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)