Detecting Rays from controller input and cast from Object
Ok, So just thinking i am on the correct track here but please help, I am trying to GetAxis() of the controller input via Horizontal and Vertical and the input manager is configured to read the joustick buttons as:
Input.GetAxis("RightStickHorizontal") Input.GetAxis("RightStickvertical")
i will then store the input as a Vector 3
i then need to cast the ray in according to the Vector 3 but from the point of a game object (the width of the ray has to be a bit wider and I am not sure on how to edit ray shapes).
The code below is rough i do not want to comit to much whilst this question is being out there as i have been at this for a while, any help is going to appriciated.
float h = CrossPlatformInputManager.GetAxis("Horizontal");
float v = CrossPlatformInputManager.GetAxis("Vertical");
Vector3 Input = h * v;
RaycashHit Hit;
//not sure if this "IF" statement is correct
if (Physics.Raycast(Player.transform.position, transform.TransfromDirection(Input),out Hit, Mathf.Infinity, layerMask))
{
//DO WHAT NEEDS TO BE DONE
}
//or this "IF" statement
if (Physics.Raycast(Player.transform.position, transform.TransfromDirection(Input),out Hit.gameobject.name("enemy"), Mathf.Infinity, layerMask))
{
//DO WHAT NEEDS TO BE DONE
}
if you can please help me with this i will be very thankful, suggestions welcome :)
Your answer
Follow this Question
Related Questions
Calculate normal vector to the plane that was hit by raycast 1 Answer
Rotate GameObject 90 degrees where is my flaw? 0 Answers
How to position an object using the w axis from Vector4? 1 Answer
Why aint my gameObject(the one i aplied the script) moving? 1 Answer
What is the best method of creating an element in a 3D environment along a specific axis? 0 Answers