|
Post by karmabiscuit on Feb 21, 2020 21:24:29 GMT
Hi there I've just recently bought the Invector melee/shooter/& locomotion assets and everything seems great so far. I was just wondering if there was an option or easy way to get the Character to attack in the direction the camera is facing for example if your character is facing forward but the camera is looking behind him, when you attack it would rotate the character to face the direction the camera is in and then attack. Instead of currently no matter the direction of the camera the character will always attack in the direction he is facing. I've already watched the guides and read through the Docs and I couldn't find it although I may just be looking over it. Thanks in advance for any help/advice.
|
|
|
Post by karmabiscuit on Feb 24, 2020 2:32:07 GMT
So I still don't know if there's just an option for it or not yet. But for anyone else wondering if there was an easy way I just made a script and added it to my character.
The first section if you want the left click to work and the second section if you want the right click to do the same.
public float rotateSpeed;
void Update() { if (Input.GetMouseButton(0) || Input.GetButton("Vertical")) { transform.rotation = Quaternion.Euler(0, Camera.main.transform.eulerAngles.y, 0); } else { transform.Rotate(0, Input.GetAxis("Horizontal") * rotateSpeed * Time.deltaTime, 0); }
if (Input.GetMouseButton(1) || Input.GetButton("Vertical")) { transform.rotation = Quaternion.Euler(0, Camera.main.transform.eulerAngles.y, 0); } else { transform.Rotate(0, Input.GetAxis("Horizontal") * rotateSpeed * Time.deltaTime, 0); } } }
|
|
|
Post by Invector on Feb 24, 2020 13:53:18 GMT
You could check the option "rotate with camera", the result would be better than rotating while attacking
|
|