Make a sprite parallel with any edge of a box

Get help using Construct 2

Post » Fri Jan 10, 2014 5:31 am

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!funkyos2014-01-10 05:32:06
B
19
S
6
G
2
Posts: 57
Reputation: 2,524

Post » Fri Jan 10, 2014 7:09 am



hope that helps
When in doubt..or you are lost in a Zombie apocalypse or someone is giving you a hard time..Remember one thing..... Read the Construct 2 Manual..it will save your life.:)
B
35
S
13
G
8
Posts: 318
Reputation: 7,685

Post » Fri Jan 10, 2014 9:44 am

@mystazsea, did you post an image? I can't see anything
B
28
S
8
G
1
Posts: 469
Reputation: 4,683

Post » Fri Jan 10, 2014 9:48 am

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. RamPackWobble2014-01-10 10:10:48
August 2015 - I misplaced a lot of links - I will try to find backups and repost. If You find a post that interests please reply to post with @rampackwobble and I will get a nudge!

If you find my posts useful please consider donating something to a local charity or to the http://www.mndassociation.org/
B
64
S
34
G
47
Posts: 1,194
Reputation: 30,892

Post » Fri Jan 10, 2014 10:42 am

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



When in doubt..or you are lost in a Zombie apocalypse or someone is giving you a hard time..Remember one thing..... Read the Construct 2 Manual..it will save your life.:)
B
35
S
13
G
8
Posts: 318
Reputation: 7,685

Post » Fri Jan 10, 2014 11:10 am

August 2015 - I misplaced a lot of links - I will try to find backups and repost. If You find a post that interests please reply to post with @rampackwobble and I will get a nudge!

If you find my posts useful please consider donating something to a local charity or to the http://www.mndassociation.org/
B
64
S
34
G
47
Posts: 1,194
Reputation: 30,892


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 28 guests