How do I pick objects intersecting a line?

Get help using Construct 2

Post » Sat Jun 18, 2016 6:55 pm

I usually just use a square sprite. Make it's origin be left center then with events set it's angle toward where you want it to end and the width to the distance and height to 1. Then to pick objects touching it it's just a matter of using the overlap condition.
B
91
S
31
G
102
Posts: 5,231
Reputation: 67,248

Post » Sat Jun 18, 2016 7:33 pm

@R0j0hound yes yes, thats the easy way but in order to use overlap you need collisions turned on. So the hard part this time was not using collisions, because i want to turn on collisions for objects in the line of fire of the player.

I'm Optimizing the game, so took down collision checks dramatically from approx 90 tick, by defaulting everything off, and just turning on for certain objects when needed. In this case, just before firing, and off again on hit. By only turning on colisions for objects in the line of fire, now my game runs at 1-2 colission checks per tick, mostly zero if any characters or bullets are not moving, or close enough to any obstacles.
Follow my progress on Twitter
or in this thread Archer Devlog
B
35
S
15
G
17
Posts: 944
Reputation: 12,210

Post » Sun Jun 19, 2016 2:04 am

Lmao looking at that formula you have there is making my eyes hurt this early in he morning. That'll teach me for trying to brain before I coffee.

Glad you resolved it :D I'll check it out again once my hamster starts running.

~Sol
Tired of crappy file hosts that are crappy? Get DROPBOX - https://db.tt/uwjysXJF
Moderator
B
80
S
34
G
40
Posts: 3,029
Reputation: 30,393

Post » Sun Jun 19, 2016 9:13 am

SoldjahBoy wrote:Lmao looking at that formula you have there is making my eyes hurt this early in he morning. That'll teach me for trying to brain before I coffee.

Glad you resolved it :D I'll check it out again once my hamster starts running.

~Sol


HAHAHA How's that for a hearty breakfast? I used the same formula elswhere in game to determine weather an object was on one or the other side of a line between two points, (without the 'abs'), and it worked. returns the distance to that line, very useful in many cases.

So credit goes to @R0j0hound for solving it earlier in this thread.
https://www.scirra.com/forum/viewtopic.php?f=147&t=148922

Awesome piece of formula.
Follow my progress on Twitter
or in this thread Archer Devlog
B
35
S
15
G
17
Posts: 944
Reputation: 12,210

Previous

Return to How do I....?

Who is online

Users browsing this forum: Twili, Yahoo [Bot] and 1 guest