Make a sprite parallel with any edge of a box

0 favourites
  • 6 posts
From the Asset Store
Over 2700 files with all the colour combinations from a 15 colours palette!
  • Hey guys,

    I have a rotating platform that's a simple rectangle. I'm trying to create a 'wall marking' on the rotating platform every time a bullet hits the platform. I need the wall marking to be parallel with the edge of the wall that the bullet collided with.

    If I use the wall's angle, it works, but only or two of the edges. For the remaining two edges, the wall marking is perpendicular.

    Here's a (failed) demo

    And here's the capx

    Thanks!

  • hope that helps

  • mystazsea, did you post an image? I can't see anything

  • First thought.

    Fire two bullets with the second slightly below the first so when they hit the angle between the two bullets should be the same as the edge - set the wall mark to the same angle.

    not tried it though....

    (edit 1)

    ok tried it and it is a start (maybe) although I expect there are much better ways.

    bullet wall angle thingy

    you could take this "found angle" and then match it to the wall angle (if found angle is almost the same as wall than make mark angle =wall angle. else do yo need to add 90/180/270 degrees ?)

    (edit 2)

    If you decide to go with this you will need to look at things like ...

    what to do if second (lower) bullet doesn't hit

    what if you hit a corner and the two bullets hit different edges.

    anyway - its an idea...

    Good luck.

  • Oh no......I was posting from my android...looks like it deleted the entire message...

    You are talking about what is known as "Decals" small sprites spawned at specific locations to indicate registered visual markers such as Bullet holes, blood splats or any other kind of mark

    I looked at the Demo you posted...

    from what I could see....

    it appears that you havent properly set the angle of the bullet Decal

    The correct sequence of events should be....

    -->On Bullet Collide with Rectangle--> Bullet Spawn another object("Decalsprite")

    ->Set "Decalsprite" Angle to Rectangle Angle

    ->Pin "Decalsprite" To Rectangle position and Angle

    Try that..

    It appears that you havent set out the Sequence of events properly

    you can tell by looking at the Sprite when its Spawned..it always appears in the verticle position no matter what angle the rectangle is and never updates its angle once attached

    Try that

    Otherwise

    A more complex method is to Calculate whats known as a "Normal"

    basically The Objects Vertical Angle from what ever Origin is..Usually 270 degrees from its 0 initial state should be Vertical..

    TO calculate the more complex method you would figure out the difference Between the Resting state"Normal" and the current Angle and apply that new Angle in Relation to the Layout ..but yeah the first method should do it...

    Hope that helps..

    sorry for the missing text

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • version 2

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