Object within angle and within range

Get help using Construct 2

Post » Mon Jul 02, 2012 12:11 am

EDIT: The problem has changed a bit. Please read the last posts.

Okay, a quick question:
How do I get the object which is inside a set angle of an other object AND within a specific distance in the set angle?

I have no problem getting an object that's within the angle but I don't know how to get the distance part. jimutt2012-07-02 15:06:56
B
8
S
3
G
2
Posts: 45
Reputation: 2,186

Post » Mon Jul 02, 2012 6:17 am

i would like you to search on forum about : tower
you will find some example may help you ^^ check these links you make use it :
http://www.scirra.com/forum/towerdefence-tower-aiming-first-enemy-in-range_topic53769.html?KW=tower
B
48
S
15
G
6
Posts: 795
Reputation: 12,035

Post » Mon Jul 02, 2012 9:06 am

Thank you! :)
Though it isn't really the most logical thing to get the word "tower" in my head when I'm looking for this ;)

Though your example is not doing what I'm looking for. This is just auto-rotating a turrent towards the player and then fireing of a bullet. What I'm creating is something of a "vision" system. And I need to detect whether the object is in a given "angle range".

Here is an example of what I mean: https://dl.dropbox.com/u/82642456/vision.jpg

EDIT: But actually I think I just came up with an idea that might work. I'll try that first. I think I just was a bit too tired when trying to do this last time.jimutt2012-07-02 09:21:05
B
8
S
3
G
2
Posts: 45
Reputation: 2,186

Post » Mon Jul 02, 2012 9:09 am

always remember there are many fans from all over the world so most of the tips are already posted of course you can ask and we will try to help you as much as we can :)
B
48
S
15
G
6
Posts: 795
Reputation: 12,035

Post » Mon Jul 02, 2012 1:25 pm

Hmm..
I'm having some issues with this. I've set up a simple example to show it:
https://dl.dropbox.com/u/82642456/obstacle.capx

The idea is to get the distance to the Obstacle object in the set angle. Though this only applies for one of the object instances. What have I done wrong?jimutt2012-07-02 13:26:05
B
8
S
3
G
2
Posts: 45
Reputation: 2,186

Post » Mon Jul 02, 2012 1:37 pm

ok i don't know the math stuffs if you use the sprites it will he us ^^ anyway change the 2nd event 2nd condition the 1st value change it from 45 to bot.angle+45 is this what you are looking for?
B
48
S
15
G
6
Posts: 795
Reputation: 12,035

Post » Mon Jul 02, 2012 1:50 pm

I guess you didn't really understand what I was asking for. All the angles are set up correctly. That is not the problem.

The problem is that if you run the program you will see that we only get a distance reading from the right obstacle. And when the Bot object is facing the left obstacle we get no distance.

So the problem is that it only gets the distance from one of the object instances.
B
8
S
3
G
2
Posts: 45
Reputation: 2,186

Post » Mon Jul 02, 2012 3:06 pm

I just noticed that if I set the Bot to face the left obstacle it only retrieves the distance for that object. So basically it only "sees" the object which it first looks at.

I hope someone will be able to help me with that.
B
8
S
3
G
2
Posts: 45
Reputation: 2,186

Post » Mon Jul 02, 2012 3:14 pm

i'm not really sure what you really need but if you fix sprites it will be must better also you can put another sprite object for the facing so when the the red object collision with the facing sprite it will set obstacle
B
48
S
15
G
6
Posts: 795
Reputation: 12,035

Post » Mon Jul 02, 2012 3:29 pm

Of course it is possible to go with an invisible "collision sprite" which is attached to the Bot object. But in my final application I will have a lot of objects on the scene at the same time and then it will be crucial for the performance to not having to use 2 sprites for each Bot object. As that will slow down performance.
B
8
S
3
G
2
Posts: 45
Reputation: 2,186

Next

Return to How do I....?

Who is online

Users browsing this forum: Colludium and 29 guests