Advertisement
Guest User

Untitled

a guest
Jan 12th, 2022
25
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. public class WallBreak : NetworkBehaviour
  2. {
  3. public float pushForce = 1000f;
  4.  
  5. private Vector3 collisionTransform;
  6. private Rigidbody rb;
  7.  
  8.  
  9. [Server]
  10. public void PushBlock(Vector3 collisionTrans, Rigidbody _rb)
  11. {
  12. rb = _rb;
  13. collisionTransform = collisionTrans;
  14. RpcAddClientForce();
  15. }
  16.  
  17. [ClientRpc]
  18. public void RpcAddClientForce()
  19. {
  20.  
  21. rb.useGravity = true;
  22. rb.AddRelativeForce((collisionTransform * pushForce)* Time.deltaTime, ForceMode.Impulse);
  23. }
  24.  
  25. }
  26.  
  27. public class IndividualBlock : MonoBehaviour
  28. {
  29. public Rigidbody rb;
  30. public WallBreak wallBreak;
  31.  
  32. private void Start()
  33. {
  34. rb = GetComponent<Rigidbody>();
  35. wallBreak = GetComponentInParent<WallBreak>();
  36. rb.useGravity = false;
  37. }
  38.  
  39.  
  40. private Vector3 collisionTransform;
  41. public void PushBlock(Transform collisionTrans)
  42. {
  43. collisionTransform = collisionTrans.forward;
  44. wallBreak.PushBlock(collisionTransform, rb);
  45. }
  46.  
  47.  
  48.  
  49. }
Advertisement
Advertisement
Advertisement
RAW Paste Data Copied
Advertisement