Skip to content

Commit

Permalink
fix: slime cannot push boxes with probability 1 rather than 1/2
Browse files Browse the repository at this point in the history
  • Loading branch information
gjwj5505 committed Dec 18, 2024
1 parent a88d67d commit 874ecf4
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions Assets/SWPPT3/Scripts/Main/PlayerLogic/PlayerMover.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
using SWPPT3.Main.Manager;
using SWPPT3.Main.PlayerLogic.State;
using SWPPT3.Main.Prop;
using SWPPT3.SoftbodyPhysics;
using Unity.Collections;
using UnityEngine;

Expand All @@ -13,7 +12,6 @@ public class PlayerMover : MonoBehaviour
{
[SerializeField] private PlayerScript _playerScript;
private Player _player;
private SoftbodyGenerator _softbody;

private float _moveSpeed;
private float _jumpForce;
Expand All @@ -30,11 +28,11 @@ public class PlayerMover : MonoBehaviour
private bool isRightButton = false;
private bool _isHoldingJump;

private int _rigidBodyId;

private void Start()
{
_player = GetComponent<Player>();
_softbody = GetComponent<SoftbodyGenerator>();

_rigidBodyId = _rb.GetInstanceID();
_moveSpeed = _playerScript.MoveSpeed;
_rotationSpeed = _playerScript.RotationSpeed;
_jumpForce = _playerScript.JumpForce;
Expand Down Expand Up @@ -85,13 +83,18 @@ public void ModificationEvent(PhysicsScene scene, NativeArray<ModifiableContactP
for (int i = 0; i < pairs.Length; i++)
{
var pair = pairs[i];

var properties = pair.massProperties;

properties.inverseMassScale = 1f;
properties.inverseInertiaScale = 1f;
properties.otherInverseMassScale = 0;
properties.otherInverseInertiaScale = 0;
if(_rigidBodyId == pair.bodyInstanceID)
{
properties.otherInverseMassScale = 0f;
properties.otherInverseInertiaScale = 0f;
}
if(_rigidBodyId == pair.otherBodyInstanceID)
{
properties.inverseMassScale = 0f;
properties.inverseInertiaScale = 0f;
}

pair.massProperties = properties;

Expand Down

0 comments on commit 874ecf4

Please sign in to comment.