Why is my Player game object not rotating with mouse movement in 'Survival Shooter' unity project
I'm a beginner to Unity trying to learn the ropes by taking the tutorial courses hosted here on the site.
I'm on the 9th phase of the course and have worked without any hitches so far.
However I downloaded the standard assets folders from the asset store this morning and on returning to the survival shooter scene on my PC found a couple of game object had their tags removed and the Player object no longer responds to mouse movement.
Please what may have gone wrong and how do I get the player to follow the mouse again?
Do you have any other GO's with attached scripts for mouse input control that are interfering? What happens when you retag your GO's? I'm presu$$anonymous$$g you imported this asset bundle into your current project
Please help me!!! I have the same problem and I checked all the layers, but they were all correct! Do you think that you know why? please let me know!
I'm another beginner with the same problem. Using the debug.log function, I have narrowed down the problem (I think) in my script to the if statement in the turning function: if(Physics.Raycast (camRay, out floorHit, camRayLength, floor$$anonymous$$ask)) I put a debug.log within this if statement and it is never accessed. Looking at the variables being passed it, they all seem to have values except for floorhit wich I can't seem to reference with the debug statement).
Any suggestions?
Thanks deepak_gamer. Using a Floor layer fixed my mouse problem.
In the Player$$anonymous$$ovement Script Just change it if (Physics.Raycast(camRay, out floorHit, floor$$anonymous$$ask))
With if (Physics.Raycast(camRay, out floorHit, camRayLength, floor$$anonymous$$ask))
Answer by Ozone Developer · Dec 24, 2014 at 07:18 AM
Thanks Sara, the problem was that the floor quad of my scene lost its layer when I imported the new assets to the scene. Correcting that solved the problem. Thanks :)
Answer by kevinmorrisone · Jul 18, 2015 at 07:41 AM
12 Days in and boy does my head hurt... =O)
Pretty unoriginal but I am just adding to this (i.e. no credit except my amazing screenshot) cuz it was annoying me AND I didn't import assets or mod the script as someone else found....soooooo...something seems to be toggling the behavior. In any case, if you are in the "Survival Shooter" Tutorial and lost your playerToMouse click on the Game Object Floor under Hierarchy and check the Layer drilldown is set to Floor.
I downloaded the assets too, but i dont know what i did and the user defined layers are not being listed in the layers list. Hence i added a new layer named "Floor" and tagged the quad to the layer "Floor". But that is not working; the player is not rotating with the mouse. Is there any particular bit value or something that i have to set to the newly created layer ?? Please help me..
Thanks $$anonymous$$morrisone for that beautiful screenshot!
thanks kevin... I must have confused the tag for the layer >.>
that is a beautiful screenshot!
Answer by Realist39 · May 17, 2016 at 10:18 PM
Had the same problem. Deleting the FLOOR object, and then creat it again, helps ME.
This is very weird but indeed, removing the floor and adding it again made it work! $$anonymous$$agic!
Answer by ThunderNoji · Oct 02, 2016 at 08:37 AM
I had the same problem and I solved it (maybe)!
Change "Main Camera" direction . - Rotate Main camera and Look down Player.
Good luck.
Answer by xela8888 · Jan 25, 2017 at 08:11 AM
This is my turning function and it seems to work fine:
void Turning() {
Ray cameraRay = Camera.main.ScreenPointToRay(Input.mousePosition);
RaycastHit floorHit;
if (Physics.Raycast(cameraRay, out floorHit, cameraRayLength, floorMask)) {
Vector3 playerToMouse = floorHit.point - transform.position;
playerToMouse.y = 0f;
Quaternion newRotation = Quaternion.LookRotation(playerToMouse);
playerRigidbody.MoveRotation(newRotation);
}
}
Your answer
Follow this Question
Related Questions
TopDown Look at mouse 0 Answers
Inventory System - picking up items 0 Answers
Scripting Approach to Mouse interaction 0 Answers
Why Does My Cube Player rotate 180 degrees when I start My game? 2 Answers