Turrets FOV and prediction aiming

Get help using Construct 2

Post » Tue Jul 24, 2012 9:55 pm

Hi all,

This problem is actually part of another thread, but the thread wasn't opened by me and I would like to add something too, so I made a new one.

I've currently hit a brick wall in my progress because a problem I thought that was fixed isn't really fixed and I have been unable to solve the problem for several days. What I need is a turret that only rotates within 178 degrees in the direction its facing, if it goes out of this range then it will locate the next nearest target and if there are no targets in range then the turret will swivel back to its original position.

This diagram explains it better.


http://dl.dropbox.com/u/57137706/turretlimitedrotate1.capx
In this capx if you look at the top right turret you will see it more clearly.

http://dl.dropbox.com/u/57137706/turretaltered.capx
This is the closest I got to it working but it breaks as much as it fixes.




If possible I would also like to add in prediction aiming to it, but there hasn't been a solution yet. The closest example I found is here.

http://dl.dropbox.com/u/57137706/aproxaim.capx

I think the reason why it don't work is because of the maths. If the maths is correct then I think it will work.

This part isn't too important because if it can't be achieved then I will make the bullets so fast that it can't be evaded, but if possible I would like a solution.

Thanks for your time everyone.

Kind Regards.


RockmanZero2012-07-24 21:58:56
B
25
S
161
G
3
Posts: 51
Reputation: 18,702

Post » Tue Jul 24, 2012 10:27 pm

I like to use a helper sprite that always points towards the enemy, and only set the angle of the object you want to restrict (in this case the turret) if that helper sprite is within a certain angle.

I don't have time to look at the prediciton right now, but maybe later.

Example: TurretAngleRestrict.capx (r99)
B
27
S
8
G
8
Posts: 903
Reputation: 8,452

Post » Tue Jul 24, 2012 10:53 pm

Many thanks Nimtrix, but is it possible to totally ignore targets that are within the no rotate zone otherwise it becomes like this.

http://dl.dropbox.com/u/57137706/turretanglerestrict1.capx

B
25
S
161
G
3
Posts: 51
Reputation: 18,702

Post » Tue Jul 24, 2012 11:10 pm

Made a new image point at the tip of the sprite and checked distance from that instead, this way the front ones will be picked over the back ones. Is that good enough?

TurretAngleRestrict2.capx (r99)Nimtrix2012-07-24 23:19:58
B
27
S
8
G
8
Posts: 903
Reputation: 8,452

Post » Tue Jul 24, 2012 11:41 pm

I'm testing it extensively but it seems to have some problems when you delete a few of the player instances. I didn't change any of the events just took out 8 instances and repositioned the other turrets. This is meant for a tower defence so it needs to work for any number of enemy units.

http://dl.dropbox.com/u/57137706/turretanglerestrict3.capx

B
25
S
161
G
3
Posts: 51
Reputation: 18,702

Post » Tue Jul 24, 2012 11:56 pm

Last edited by Yann on Sun Sep 14, 2014 9:08 pm, edited 1 time in total.
B
60
S
22
G
14
Posts: 1,479
Reputation: 16,346

Post » Wed Jul 25, 2012 12:15 am

Very nice @Yann, I should read up on the angle expressions. I had overlooked anglediff, should definitely start using that.
B
27
S
8
G
8
Posts: 903
Reputation: 8,452

Post » Wed Jul 25, 2012 12:51 am

Here's my attempt: turretFOV.capx

I wasn't aware of the anglediff expression either so the angleChecker sprite isn't really necessary. The turrets follow the first target they pick up until it moves out of range which is I think what you want.

*edit* using anglediff: turretFOV2.capxramones2012-07-25 00:59:38
B
54
S
28
G
18
Posts: 1,520
Reputation: 24,990

Post » Wed Jul 25, 2012 1:11 am

Many many thanks Nimtrix, Yann and Ramones that is exactly what I wanted.

B
25
S
161
G
3
Posts: 51
Reputation: 18,702


Return to How do I....?

Who is online

Users browsing this forum: Draconinho, peturfoto and 14 guests