Hello everyone! I am working on setting up a “targeting state” for my player right now using state machine system and Unitys new input system. Basically there is a large invisible trigger collider around the player, and when the targeting button is pressed, we switch from “free movement” to “targeting movement”, as in movement becomes relative to the target, and the camera switches from being controlled by the player to being locked on to the player and the target. If there are multiple targets the one closest to the middle of the screen is chosen, and while locked on to a target the camera can be tilted slightly in all directions to switch targets. A button is assigned to switching targets which clears the current target, and checks all current available targets for the one closest to the center of the screen again.
…I’m pretty bad at describing things so I made a video demonstrating what I have working, as well as what problems I am having… My main issue right now is trying to tilt the camera when looking at a target only works from the front… I am using a cinema chine targeting group camera to look at the player, the target, and an additional object that is placed at the targets transform position. The additional object is controllable with the right thumbstick but only moves correctly from the front. When releasing the thumbstick the object returns to the target position which recenters the view. The other main issue is this method doesn’t work with mouse and keyboard controls. The other issues are minor things I’m sure I can work out along the way but these first 2 things are really keeping me from making much progress.
As I’m using a state machine there’s at least 3 different scripts all working together here, so rather than posting them all out here and making this longer than it already is I’ve uploaded a stripped down version of the projects to google drive, and the download link can be found here: Dropbox
I realize I’m kinda asking a lot here but I’m really stuck here and wanted to see if anyone else had any ideas on how to do things better. I’m still so new to all this 3d stuff so figuring out quaternions and rotations in a 3d space is all very new and challenging to me. Thank you for reading and again, any help is greatly appreciated! && If you find anything useful in the project file, feel free to borrow!! Have a great day!!