(SOLVED) Look rotation viewing vector is zero

i am making an online shooter but when i look at half of my map an notice appears in the console

Look rotation viewing vector is zero
UnityEngine.Quaternion:LookRotation(Vector3)

i also see that my bullet gets a weird impact location then. instead of hitting the target it (the hit effect) spawns at a 0,0,0 location in my game (center of my map).
why is this happening and how can i fix this?
thanks alot,
kelvin

Hard to help without code. Post the full stacktrace, usually the top is where the error is if it’s not an internal error:
Look rotation viewing vector is zero UnityEngine.Quaternion:LookRotation(Vector3, Vector3) UnityEditorInternal.MethodName() (at C:/path/ScriptThatWentWrong:lineNumber

Bold is the information that matters.

Look rotation viewing vector is zero
UnityEngine.Quaternion:LookRotation(Vector3)
PlayerShoot:RpcDoHitEffect(Vector3, Vector3) (at Assets/Scripts/PlayerShoot.cs:78)
PlayerShoot:InvokeRpcRpcDoHitEffect(NetworkBehaviour, NetworkReader)
UnityEngine.Networking.NetworkIdentity:UNetStaticUpdate()

my code that the message is pointing to:
(this is inside the PlayerShoot script)

[ClientRpc]
    void RpcDoHitEffect(Vector3 _pos, Vector3 _normal)
    {
        GameObject _hitEffect = (GameObject)Instantiate(weaponManager.GetCurrentGraphics().hitEffectPrefab, _pos, Quaternion.LookRotation(_normal));
        Destroy(_hitEffect, 2f);
    }

Code tags when posting code, for future reference.

The error must be with the LookRotation method there. The _normal vector can’t be zero (what’s the direction of a vector that points nowhere?).

The code that calls that RPC must be erroneous. If the vectors being given to the method are both zero then that would explain the error and why it’s instantiating at 0, 0, 0.

LookRotation expects a non-zero vector3. if you feed it a zero vector it’ll just return a Quaternion.identity (which is default rotation and doesn’t rotate an object if you multiply against it).

its a harmless message, hence it using Debug.Log instead of Warning or Error. but just as well its best to check if the look vector is zero and if so use Quaternion.Identity, just so it doesn’t pollute your console.

i checked it and it isnt just when i face 1 way. it gives this error almost 180 degrees towards the middle of the map
and how can i stop it from being 0,0,0 then?

OH just why… if the range of the raycast is infinite then it does that debug.log. i made walls around my map and now it does NOT give the error. can some one tell me why???

sounds like your using the raycast data even if it doesn’t hit anything. Physics.Raycast return a boolean telling if the raycast actually hit anything. if it doesn’t hit anything you shouldn’t even have to spawn hit graphics.

I mean if you shoot into the sky… what… you expect bullet hole decals particle effecent and hit sounds to generate on the skybox?

what ever is calling your RpcDoHitEffect, it should first check if the raycast actually hit something. it doesn’t quite make sense to apply hit effects even if you don’t actually hit anything.