Direction of collision?

Get help using Construct 2

Post » Sun Oct 25, 2015 2:34 am

is there a way to get the direction of a collision?

I know it would be as simple a angle(self.X,self.Y,other.X,other.Y)
but other isn't a valid expression
B
13
S
6
G
1
Posts: 149
Reputation: 1,960

Post » Sun Oct 25, 2015 4:38 am

Get the sprites angle. it is SpriteName.Angle if you use it in an expression.

Hope that is what you are asking.
B
29
S
8
G
4
Posts: 767
Reputation: 5,985

Post » Sun Oct 25, 2015 4:56 am

well I was looking to turn it into a function so I can reuse it
however if I define it by name it wouldn't be reusable

I was wanting to address it via the collision event so I can somehow return the object that is colliding with me
B
13
S
6
G
1
Posts: 149
Reputation: 1,960

Post » Sun Oct 25, 2015 6:13 am

If you're using the on collision event you specify the type to check for collision with, so you could use the angle() expression. Just use the other object type instead of other.

Or if you make a family, call it other, and then use an event like this:
Sprite: on collision with other

That way you can use your expression exactly. Also this is the recommended way to handle collisions between two objects of the same type.
B
92
S
32
G
109
Posts: 5,290
Reputation: 70,991

Post » Sun Oct 25, 2015 6:18 pm

k I'll try it
B
13
S
6
G
1
Posts: 149
Reputation: 1,960

Post » Sun Oct 25, 2015 11:39 pm

family's are just a bad way around it
It just makes it harder to understand
B
13
S
6
G
1
Posts: 149
Reputation: 1,960


Return to How do I....?

Who is online

Users browsing this forum: BackendFreak, farsen, newt, TRMG and 24 guests