Tank Turret Rotation!

0 favourites
  • 13 posts
From the Asset Store
Try to destroy your enemies in a hard battle! Good luck!
  • 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.

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

  • 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!!

  • 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.

  • 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.

  • TheDoctor 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!

  • Try adding a Physics behavior the the turret and another Physics behavior with Immovable set to true on the walls.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • 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.

  • 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..

  • Thank you all,and here's a simple scene featuring a tank and one obstacle with Solid Behavior.Give it a try people!

  • I'm still trying!!

  • I'm working on at Tank type game myself and even if this scenario is not part of my current project, I decided to take your challenge!

    I looked at your tank.capx and your starting with the wrong logic. Part of the answer is in your first post (I put it in Bold in the quote).

    Hi everyone;

    ......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?

    Set angle towards mouse will not work, you need to have it rotate towards the mouse.

    If you move the mouse very quickly with the set angle condition you will notice how it jerk's to the new angle, but if you tell it to rotate towards the mouse the turret simply change's direction and continues to rotate a the same speed no matter how fast you move your mouse.

    Now to work on that obstacle problem.

  • Well it's not perfect, seams to bounce when colliding with corners but work's well along the wall.

    Happy tweaking!

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)