Turret Behaviour - Set max rotation angle

Just started using Construct 2? Post your questions here

Post » Thu May 29, 2014 9:25 pm

Hi

does anyone know if it's possible to set the max rotation angle on a turret?
I'm using the turret behaviour for a weapon that sits on the floor. If the target is also on the floor the weapons angles itself into the floor slightly, looking weird.

There's physics in this game, and adding physics to the weapon did not help as the rotation point changed to the middle of the weapon sprite.

I've attached an image showing the issue, any help appreciated.

Thanks.

ScreenHunter_38 May. 29 22.18.jpg
You do not have the required permissions to view the files attached to this post.
B
10
S
2
G
1
Posts: 42
Reputation: 798

Post » Fri May 30, 2014 4:19 am

Check the example @EgoAnt posted in this other topic:

viewtopic.php?f=147&t=106081

He has 2 turrets, each with a different allowed angle of rotation.
B
40
S
12
G
11
Posts: 331
Reputation: 7,752

Post » Fri May 30, 2014 7:08 am

@FragFather

Thanks for pointing me to that. It's a good example of setting a rotation value for a sprite, but it doesn't use the turret behaviour.
I want to keep my turrets with the turret behaviour if possible.

Thanks.
B
10
S
2
G
1
Posts: 42
Reputation: 798

Post » Fri May 30, 2014 1:37 pm

Hi,
Try this:

1. Fix your nitial turret angle, suppose it is initAngle = x
2. Fix the Min & Max angles of Turret, suppose are: MinAngle, MaxAngle

Goto eventsheet and add this event:
EVENT:
yourTurret ..Is between MinAngle and MaxAngle degrees

ACTION:
yourTurret..Set angle to initAngle degrees.

let me know the result?
2D Game GUI Designer
B
12
S
4
G
3
Posts: 130
Reputation: 3,778

Post » Fri May 30, 2014 2:57 pm

@Manarsoft

many thanks for the help. I've done as you suggested (or as close as I can work out) and using regular Set Angle outside of the physics group does indeed set the turret angle to whatever I tell it. However it's an instant movement of the angle so it doesn't look great.

So I changed Set Angle to Rotate Towards Angle, and that basically does the same.

I've also tried unacquiring the the target too, to stop the tracking as soon as it sees it again while rotating it away from the target, still no luck.

If you have the time, I've attached my capx.

Thanks.
You do not have the required permissions to view the files attached to this post.
B
10
S
2
G
1
Posts: 42
Reputation: 798


Return to Beginner's Questions

Who is online

Users browsing this forum: No registered users and 0 guests

cron