Tank Turret Rotation!

Get help using Construct 2

Post » Sun Mar 09, 2014 12:58 am

Hi everyone;
I'm working on a top down shooter game and my main object is a static tank with a moving turret, but the problem I'm facing is when the turret is rotating and hits a wall or some kind of obstacle, the turret is keep moving and never stops! Any tip around?

Thanks a lot.
B
13
S
4
G
4
Posts: 42
Reputation: 3,962

Post » Sun Mar 09, 2014 3:20 am

So what do want to happen when the turret hits the wall and what kind of movement is it doing now?
B
19
S
7
G
7
Posts: 88
Reputation: 4,117

Post » Sun Mar 09, 2014 9:07 am

TheDoctor wrote:So what do want to happen when the turret hits the wall and what kind of movement is it doing now?



Simply I want the turret to act as a real tank turret, stop rotating when hits the obstacle and stop following the mouse arrow. I tried making both the turret and the obstacle a solid objects and I switched the Collision On for my turret,but when the turret hit something it shifting it's center away from the tank body!!
B
13
S
4
G
4
Posts: 42
Reputation: 3,962

Post » Sun Mar 09, 2014 1:49 pm

Did you give the turret the behavior "PIN" and then pin it to the tank body?

I would also put both of them in a container so that both are created/destroyed and such together.
B
19
S
7
G
7
Posts: 88
Reputation: 4,117

Post » Sun Mar 09, 2014 1:59 pm

Turret on Collision with Wall => set turret Self.Angle -1

This would get it to not penetrate the wall, it will always move 1 angle away even if you move your mouse (if turret was aiming at mouse).

If you need it both sides of the tank, then just add an extra instance variable of the wall, and add a condition to the collision check, If Wall = 0 (left) then set turret angle +1, and if its = 1 (right) then -1.

Hopefully that helps.
B
70
S
24
G
19
Posts: 1,757
Reputation: 17,614

Post » Tue Mar 11, 2014 12:00 am

@TheDoctor @Silverforce Thanks a lot for your responses but nothing seems to be working here!! I tried in many ways! The concept is really simple just like Rigid Bodies in 2D or 3D environment!
B
13
S
4
G
4
Posts: 42
Reputation: 3,962

Post » Tue Mar 11, 2014 12:08 am

Try adding a Physics behavior the the turret and another Physics behavior with Immovable set to true on the walls.
B
11
S
3
G
4
Posts: 38
Reputation: 3,447

Post » Tue Mar 11, 2014 2:03 am

Well, the more physics you add the more it costs you on processing and frame rate, most likely.

So what exactly is your turret doing now?

This seems like a totally doable.
B
19
S
7
G
7
Posts: 88
Reputation: 4,117

Post » Tue Mar 11, 2014 8:49 am

You could probably just do something with overlapping at offset and setting the angle to itself if so.
But it's hard for me to form a picture from what you are saying, so there might be better or easier solutions.
Please share a capx or show us a picture and/or eventsheet for this issue..
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Tue Mar 11, 2014 11:40 am

Thank you all,and here's a simple scene featuring a tank and one obstacle with Solid Behavior.Give it a try people!
You do not have the required permissions to view the files attached to this post.
B
13
S
4
G
4
Posts: 42
Reputation: 3,962

Next

Return to How do I....?

Who is online

Users browsing this forum: dop2000, uzumiapps and 31 guests