How do I trigonometrizzle this?

Get help using Construct 2

Post » Mon Jun 27, 2016 9:54 pm

Image ImageImage
B
170
S
50
G
179
Posts: 8,381
Reputation: 113,431

Post » Tue Jun 28, 2016 1:19 am

@facecrime
You can manually do the math the way your picture shows, or you can let C2 do the work for you.

I whipped up a sample - where I pin circular sprites to the player and enemy and then test for overlapping (these can be set to invisible, but I left them showing so you can see what is happening). Player has 8-direction behavior so you can move him around. Enemy has bullet behavior and always moves towards Player.

It doesn't do any obstacle avoidance - because I have no idea what your layout looks like, but this might give you some ideas to try out.

capx: http://www.rieperts.com/games/forum/RotatingEnemy.capx
B
98
S
35
G
20
Posts: 438
Reputation: 17,875

Post » Tue Jun 28, 2016 8:32 pm

@newt thanks for your example, helped me a bunch. I originally thought you were using LoS somehow to determine that intersection point, but I do of course also use it to check for range and actual LoS.
but what I was really missing is retrieving that intersection point, and you just casually threw that in there. thanks again, exactly what I need.

@AllanR thanks for putting that together, very slick. it's actually close to what I had, but I need to get rid of the bullet behaviour for a few reasons.

Here's what it looked like:
Image

That's of course smoother than what I'll be getting with pathfinding, but that's ok, cos the circular path doesn't matter so much
B
15
S
6
Posts: 232
Reputation: 1,931

Previous

Return to How do I....?

Who is online

Users browsing this forum: No registered users and 28 guests