How do i make a turet that can lock on to an enemy

i am trying to make a turet for a space ship but i cant get it right please help

Hi, can you give a bit more information? Is it a top down game or another perspective? You wrote that you cannot get it right, so you seem to have some events. It would be helpful if you could post them here as well.

I don’t know if this is of any help but in a platformer game I built I had an enemy instantly turn towards an enemy for example if the player stood at the right the character turned to that direction and fired if the player was in a certain distance.

I used an object variable for the snowman using direction “right”

You may be able to alter the code somewhat for what you need.

The direction

Attack events

1 Like

There are countless different ways to lock onto an enemy. You need to pick one before anyone can help.

Set a raycast to the enemy

1 Like

If it’s a top down game then have the turret rotate towards the player or enemy, if it’s a Platformer then I guess do the same thing

It’s pretty simple

1 Like

ooh yea sorry i am new to the game making forum so its a top down space shooter where you can place a turret on you ship and it goes automaticly

Okay, there is an action called ‘Rotate toward position’.

rotate2

You have to decide about the condition, maybe when the enemy is in a certain range?

This example rotates the turret all the time towards the mouse position:

One thing is very important for the event to work: your sprite has to be aligned correctly before you load it into your project. The muzzle of your turret has to be in eastern direction (or to the right) at 0, as the front of the car in this image:
degree

You can read about rotating objects here: How to rotate objects - GDevelop documentation