- Home /
This question was
closed Sep 11, 2018 at 10:32 AM by
ensareray99 for the following reason:
Solved
Question by
ensareray99 · Sep 11, 2018 at 10:22 AM ·
physicsraycastlayersray
When i bring my mouse on layer mask my player doesn't move
I'm trying to rotate player with mouse and using Raycast for it but when i bring my mouse on the ground object my player moves gets slows down and freeze. This is my code for it waiting for your helps
void Update () {
Movement();
LookingMouse();
}
void Movement()
{
float moveH = Input.GetAxisRaw("Horizontal");
float moveV = Input.GetAxisRaw("Vertical");
Vector3 moveVector = new Vector3(moveH,0,moveV);
rb.MovePosition(rb.position+ moveVector.normalized * Time.deltaTime* Speed);
}
void LookingMouse()
{
Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
RaycastHit hit;
if(Physics.Raycast(ray,out hit,layer))
{
transform.LookAt(hit.point);
}
}
Comment