Top Down Enemy Target / Aim Ability Help

UncleJohn

New member
I was hoping that someone could help point me in the right direction to solving my aiming problem with the Top Down setup.

My character currently walks around the world facing where they are walking as they should.
Now I would like to have my character detect enemies within a range and target the enemy closest to where the character is currently facing with a visual indicator.
Then I would like to move the Right Joystick and have my character aim at the target and shoot the weapon.
While shooting I want to rotate the Right stick to switch to other targets within range and continue shooting.
When I release the Right stick the character will stop shooting and move around as they were originally.

Is this something that anyone has done or could help me figure out how to do?
Any help would be greatly appreciated!
 
This will take some modification within the TopDown Movement Type. I would create a new Movement Type that inherits Top Down that adjusts the GetDeltaYawRotation based on the target location. You could also do this with a new ability but I think that it's more appropriate for the Movement Type.
 
This will take some modification within the TopDown Movement Type. I would create a new Movement Type that inherits Top Down that adjusts the GetDeltaYawRotation based on the target location. You could also do this with a new ability but I think that it's more appropriate for the Movement Type.
Thank you!
My coding skills are not skills at all. However, I am always wanting to learn.
I read the movement types section in the documentation but I am a little lost on how to begin. Are there any other examples or tutorials on how to build new movement types like this? Or any other info you could point me to so I can learn how to do this?
 
For just getting started with coding I recommend going through the Unity Learn tutorials first.


This will take some time to go through but will really pay off. The character controller uses a lot of the concepts discussed in the scripting course so while it's not specifically talking about our character controller you will still benefit greatly from it. From there you'll understand what I mean when I say to subclass the TopDown Movement Type and override the GetDeltaYawRotation method :)
 
For just getting started with coding I recommend going through the Unity Learn tutorials first.


This will take some time to go through but will really pay off. The character controller uses a lot of the concepts discussed in the scripting course so while it's not specifically talking about our character controller you will still benefit greatly from it. From there you'll understand what I mean when I say to subclass the TopDown Movement Type and override the GetDeltaYawRotation method :)
Well I'm not that bad lol. I was just wondering if there were some more examples other than that small page? Or just a little bit more explanation.
 
Ah, in that case I recommend that you first take a look at the component organization page:


From there the Movement Type page has some basic info on how to create a new Movement Type:


After that you can use the Object Browser within your IDE to get an overview of the methods. All of the methods are commented so it makes it really easy to browse. But looking at the existing Movement Types is also a great strategy and setting breakpoints to look at the flow of the logic.
 
Top