renormalize line endings to LF
Mechanical consequence of the .gitattributes in the previous commit, done in one deliberate pass rather than left to trickle out as surprise diffs whenever someone next touches a vendored file. 74 files, all CRLF -> LF, 71 of them in StarterAssets. `git diff -w` over this commit is empty: nothing but line endings changed. DialogueTest.unity is correctly untouched, being marked binary. Co-Authored-By: Claude Opus 5 <[email protected]>
This commit is contained in:
+34
-34
@@ -1,35 +1,35 @@
|
||||
using UnityEngine;
|
||||
|
||||
public class BasicRigidBodyPush : MonoBehaviour
|
||||
{
|
||||
public LayerMask pushLayers;
|
||||
public bool canPush;
|
||||
[Range(0.5f, 5f)] public float strength = 1.1f;
|
||||
|
||||
private void OnControllerColliderHit(ControllerColliderHit hit)
|
||||
{
|
||||
if (canPush) PushRigidBodies(hit);
|
||||
}
|
||||
|
||||
private void PushRigidBodies(ControllerColliderHit hit)
|
||||
{
|
||||
// https://docs.unity3d.com/ScriptReference/CharacterController.OnControllerColliderHit.html
|
||||
|
||||
// make sure we hit a non kinematic rigidbody
|
||||
Rigidbody body = hit.collider.attachedRigidbody;
|
||||
if (body == null || body.isKinematic) return;
|
||||
|
||||
// make sure we only push desired layer(s)
|
||||
var bodyLayerMask = 1 << body.gameObject.layer;
|
||||
if ((bodyLayerMask & pushLayers.value) == 0) return;
|
||||
|
||||
// We dont want to push objects below us
|
||||
if (hit.moveDirection.y < -0.3f) return;
|
||||
|
||||
// Calculate push direction from move direction, horizontal motion only
|
||||
Vector3 pushDir = new Vector3(hit.moveDirection.x, 0.0f, hit.moveDirection.z);
|
||||
|
||||
// Apply the push and take strength into account
|
||||
body.AddForce(pushDir * strength, ForceMode.Impulse);
|
||||
}
|
||||
using UnityEngine;
|
||||
|
||||
public class BasicRigidBodyPush : MonoBehaviour
|
||||
{
|
||||
public LayerMask pushLayers;
|
||||
public bool canPush;
|
||||
[Range(0.5f, 5f)] public float strength = 1.1f;
|
||||
|
||||
private void OnControllerColliderHit(ControllerColliderHit hit)
|
||||
{
|
||||
if (canPush) PushRigidBodies(hit);
|
||||
}
|
||||
|
||||
private void PushRigidBodies(ControllerColliderHit hit)
|
||||
{
|
||||
// https://docs.unity3d.com/ScriptReference/CharacterController.OnControllerColliderHit.html
|
||||
|
||||
// make sure we hit a non kinematic rigidbody
|
||||
Rigidbody body = hit.collider.attachedRigidbody;
|
||||
if (body == null || body.isKinematic) return;
|
||||
|
||||
// make sure we only push desired layer(s)
|
||||
var bodyLayerMask = 1 << body.gameObject.layer;
|
||||
if ((bodyLayerMask & pushLayers.value) == 0) return;
|
||||
|
||||
// We dont want to push objects below us
|
||||
if (hit.moveDirection.y < -0.3f) return;
|
||||
|
||||
// Calculate push direction from move direction, horizontal motion only
|
||||
Vector3 pushDir = new Vector3(hit.moveDirection.x, 0.0f, hit.moveDirection.z);
|
||||
|
||||
// Apply the push and take strength into account
|
||||
body.AddForce(pushDir * strength, ForceMode.Impulse);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user