NEED HELP WITH MY SCRIPT CAMERA SHAKE

i use unity's FPS controller.i manage to make camera shake on the other players.

the idea is. i shoot, my camera shakes. and when enemy is hit, his camera shakes as well. like feeling the impact.

so i manage to do this. i use allbuffered. but the problem is, everyone who are not hit are affected as well. i was confused. i manage to do this with damage health script without any problem. (only the target is affected).
but with the camera shake. it affects everyone. did i miss something or is it something with photonnetwork target?

i use raycast. and store all my hit components. and able to read parent or child.

i will show you the script. it may be dirty. was really want to manage how to fix this issue. i have the clean version one before i try to do camera shake on enemies cam.



my goal for this is, i only want the enemie's cam to shake(who is hit by my raycast) would be the only one affect. not everyone else or yourself.



https://forum.unity3d.com/threads/need-help-with-camera-shake-photon-unity.477194/

Comments

  • Hi @irvintiu,

    you are sending the RPC to each client when using PhotonTargets.AllBuffered. That means that each client will execute the RPC. In the called function you are using Camera.main to access the camera. Since each client has a main camera, the result is that each client's camera is shaking. What you have to do is to send the RPC to a specific player instead of PhotonTargets.All. Also Buffering is not recommended and should be avoided in this case because it is simply not important for late-joining clients.
  • Hi @irvintiu,

    you are sending the RPC to each client when using PhotonTargets.AllBuffered. That means that each client will execute the RPC. In the called function you are using Camera.main to access the camera. Since each client has a main camera, the result is that each client's camera is shaking. What you have to do is to send the RPC to a specific player instead of PhotonTargets.All. Also Buffering is not recommended and should be avoided in this case because it is simply not important for late-joining clients.

    thats true. but how do i do that for specific client?
  • You can pass a PhotonPlayer as parameter instead of PhotonTargets.*. In your case this should be h.GetComponent< PhotonView >().owner.
  • You can pass a PhotonPlayer as parameter instead of PhotonTargets.*. In your case this should be h.GetComponent< PhotonView >().owner.

    im having error with .owner XD
  • You can pass a PhotonPlayer as parameter instead of PhotonTargets.*. In your case this should be h.GetComponent< PhotonView >().owner.

    never mind. just figured it out XD you my friend are the man!

    what i did, i set


    var pv = h.GetComponent< PhotonView >().owner


    and

    photonView.RPC("TakeDamage", pv, force); //that way i can do damage only on a specific photon view XD