How do I create a player-controlled turret

Get help using Construct 2

Post » Fri May 23, 2014 2:45 pm

Hey everyone!

I'm working on a landscape-oriented project right now and I would really like to create a turret which can be controlled by a player. Unfortunately, I don't know how to do it, so I would like to know if anyone here knows any good tips on how to accomplish this.
B
4
Posts: 25
Reputation: 256

Post » Fri May 23, 2014 3:32 pm

What type of control do you want? Do you want the turret to point at the mouse or turn with the keyboard?
Visit me at EgoAnt.com
B
51
S
7
G
7
Posts: 78
Reputation: 6,408

Post » Fri May 23, 2014 4:21 pm

I'd like to make it turn with the keyboard, hopefully. Preferably with the left and right arrow keys (It's only supposed to move on a limited angle)
B
4
Posts: 25
Reputation: 256

Post » Fri May 23, 2014 5:39 pm

Auto fire, or by key press?
Visit me at EgoAnt.com
B
51
S
7
G
7
Posts: 78
Reputation: 6,408

Post » Fri May 23, 2014 5:41 pm

I want it to be constantly firing, like a turret-mounted flashlight, so to speak.
B
4
Posts: 25
Reputation: 256

Post » Fri May 23, 2014 5:54 pm

1 - Create a variable called angle and set it to 0. This will represent a value of 0 to 359.
2 - When a direction key is pressed, add/subtract a value from angle depending on how much you want the turret to turn.
3 - Set the sprites angle to the value in angle.
4 - When angle >= 360, set angle = angle - 360. This keeps angle within the 0 to 359 values.
5 - Set the angle of the spawned "bullet" items to the same value as the turret.
B
39
S
12
G
11
Posts: 331
Reputation: 7,727

Post » Fri May 23, 2014 5:58 pm

Okay, here is an example that allows you to place a turret anywhere on the screen and have it limited by min and max rotation range. It's saved as the latest beta version.
You do not have the required permissions to view the files attached to this post.
Visit me at EgoAnt.com
B
51
S
7
G
7
Posts: 78
Reputation: 6,408

Post » Fri May 23, 2014 6:00 pm

I put two turrets in there so you could see how the min and max values could be set on a per-turret basis.
Visit me at EgoAnt.com
B
51
S
7
G
7
Posts: 78
Reputation: 6,408

Post » Sun May 25, 2014 1:17 pm

That's great! Do you guys know of a way to interact with the turret? Like, only being able to rotate it if the player decided to press E right next to it in order to use it, while also forcing the player to stand still while he interacts with it. Also, any idea on how to make the turret fire constantly, regardless of whether I'm using it or not? Like a laser beam, or something similar.
B
4
Posts: 25
Reputation: 256

Post » Mon May 26, 2014 5:26 pm

I'll see what I can do about this today.
Visit me at EgoAnt.com
B
51
S
7
G
7
Posts: 78
Reputation: 6,408

Next

Return to How do I....?

Who is online

Users browsing this forum: diamantico21, ratboy3, TRMG and 36 guests