- Home /
How would one go about creating a Targeting System similar to the z-targeting in LoZ?
I've seen a couple questions ask this but I've yet to see a comprehensive answer.
But, in general, I'm trying to figure out how I would go about coding a camera that would, after selecting a target, position itself behind the player and only allow the play to circle-strafe around that target (This is where I'm stuck).
I need to know how to go about making it so the player, when pressing the left and right movement keys, move in a way that orbits the target instead of how it generally lets them run, without any restraints, to the left and right.
Anyone out there got an explanation or a way I can go about implementing this?
I imagine there is a way that calculates the size of a circle, but I think it may be easier to have a secondary object that gets used as the players position system. Basically when you select the location or target, the object moves to the location, the player gets childed to the object, then his movement gets locked and he can now move differently, where left and right would actually rotate the object. If this doesn't make sense, I suppose I could code an example up.
Can you tell us a little bit more about your camera and input set up? For example, is the direction the player character moves relative to itself or to the camera?
In any case, what you can do is find a way to force the player character to look at the target via script. This can be done with the transform.rotation.SetLookRotation, for example. Then, just map the Horizontal input axis to the strafing of the character. This will automatically make the character move in a circle around the target.
THe movement of the character is relative to the camera. And that sounds interesting, I can attempt that later on today.
Answer by CrimOudin · May 19, 2017 at 01:53 PM
If you rotate your character toward the target then their local left and right will change. You can use the local axis' to determine where you will move next.
Answer by CoughE · May 19, 2017 at 01:57 PM
A simple way to do it, would be make the camera/player LookAt the target. Then after that, only allow the player to move left or right. This way the player will face the target, move to the left and face the target again, effectively orbiting them
Your answer
Follow this Question
Related Questions
Camera/can't turn on X 1 Answer
UNITY 3D: How to make the camera follow the player? Smoothly 2 Answers
Camera Follow a Target, but not Centered on it 1 Answer
Mouse movement object in a straight line 2 Answers
Move relative to screen 0 Answers