Advertisement
Coolsonickirby

Scripts

Jul 11th, 2018
678
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.94 KB | None | 0 0
  1. HedgeCamera code
  2.  
  3. public bool is2D;
  4. public float x2D;
  5. public float y2D;
  6. public float z2D;
  7. public float CameraMaxDistance2D;
  8. -----------------------------------------------------
  9. if (is2D == false)
  10. {
  11. if (!UseCurve)
  12. {
  13. float NormalMod = Mathf.Abs(Player.b_normalSpeed - Player.MaxSpeed);
  14. x += (((Input.GetAxis("Horizontal")) * NormalMod) * AutoXRotationSpeed) * Time.deltaTime;
  15. ;
  16. y -= 0;
  17. z = 0;
  18. }
  19. else
  20. {
  21.  
  22. CurveX = AutoXRotationCurve.Evaluate((Player.rigidbody.velocity.sqrMagnitude / Player.MaxSpeed) / Player.MaxSpeed);
  23. CurveX = CurveX * 100;
  24. x += (((Input.GetAxis("Horizontal")) * CurveX) * AutoXRotationSpeed) * Time.deltaTime;
  25. ;
  26. y -= 0;
  27. z = 0;
  28. }
  29. }
  30. else
  31. {
  32.  
  33. x = x2D;
  34. ;
  35. y = y2D;
  36. z = z2D;
  37.  
  38. CameraMaxDistance = CameraMaxDistance2D;
  39.  
  40. }
  41.  
  42.  
  43. __________________________________________________________________________
  44. 2D Trigger Script
  45.  
  46. public State Types;
  47. public float X;
  48. public float Y;
  49. public float Z;
  50. public float CameraDistance;
  51. public enum State
  52. {
  53. Disable2D, FreezeXAxis, FreezeYAxis, FreezeZAxis
  54. }
  55.  
  56. __________________________________________________________________________
  57. Object_Interactions Script
  58.  
  59. if (col.tag == "2DTrigger") {
  60. if (col.GetComponent<Trigger2D>().Types != Trigger2D.State.Disable2D)
  61. {
  62. Cam.is2D = true;
  63. Cam.x2D = col.GetComponent<Trigger2D>().X;
  64. Cam.y2D = col.GetComponent<Trigger2D>().Y;
  65. Cam.z2D = col.GetComponent<Trigger2D>().Z;
  66. Cam.CameraMaxDistance2D = col.GetComponent<Trigger2D>().CameraDistance;
  67. if (col.GetComponent<Trigger2D>().Types == Trigger2D.State.FreezeXAxis)
  68. {
  69. Player.rigidbody.constraints = RigidbodyConstraints.FreezePositionX | RigidbodyConstraints.FreezeRotation;
  70. }
  71. if (col.GetComponent<Trigger2D>().Types == Trigger2D.State.FreezeYAxis)
  72. {
  73. Player.rigidbody.constraints = RigidbodyConstraints.FreezePositionY | RigidbodyConstraints.FreezeRotation;
  74. }
  75. if (col.GetComponent<Trigger2D>().Types == Trigger2D.State.FreezeZAxis)
  76. {
  77. Player.rigidbody.constraints = RigidbodyConstraints.FreezePositionZ | RigidbodyConstraints.FreezeRotation;
  78. }
  79. }
  80. else {
  81. Cam.is2D = false;
  82. Cam.CameraMaxDistance = -30;
  83. Player.rigidbody.constraints = RigidbodyConstraints.None;
  84. Player.rigidbody.constraints = RigidbodyConstraints.FreezeRotation;
  85. }
  86. }
  87. __________________________________________________________________________
  88. One Way Script
  89.  
  90.  
  91. using System.Collections;
  92. using System.Collections.Generic;
  93. using UnityEngine;
  94.  
  95. public class OneWay : MonoBehaviour {
  96.  
  97.  
  98. public ColliderObject ColliderType;
  99. BoxCollider collisionbox;
  100. MeshCollider collisionmesh;
  101.  
  102. public enum ColliderObject{
  103. BoxCollider, MeshCollider
  104. }
  105. private void Start()
  106. {
  107. collisionbox = GetComponent<BoxCollider>();
  108. collisionmesh = GetComponent<MeshCollider>();
  109. }
  110.  
  111.  
  112. private void OnTriggerExit(Collider other)
  113. {
  114. if (ColliderType == ColliderObject.BoxCollider)
  115. {
  116. collisionbox.isTrigger = false;
  117. }
  118. if (ColliderType == ColliderObject.MeshCollider)
  119. {
  120. collisionmesh.convex = false;
  121. collisionmesh.isTrigger = false;
  122. }
  123.  
  124. }
  125. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement