Skip to content

Commit e886207

Browse files
committed
Little tweaks
1 parent 0d9ac51 commit e886207

File tree

3 files changed

+10
-6
lines changed

3 files changed

+10
-6
lines changed

engine/Assets/Scripts/Drivers/RotationalDriver.cs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
using UnityEngine;
99
using Synthesis.Util;
1010
using Synthesis.Physics;
11+
using Math = System.Math;
1112

1213
#nullable enable
1314

@@ -283,6 +284,7 @@ private void VelocityControl(float deltaT) {
283284
if (Mathf.Abs(_lastVel) > _convertedMotorTargetVel)
284285
_lastVel = _convertedMotorTargetVel * Mathf.Sign(_lastVel);
285286

287+
float lastFakedTheta = _fakedTheta;
286288
_fakedTheta += _lastVel * deltaT;
287289

288290
if (_rotationalLimits.HasValue) {
@@ -291,11 +293,12 @@ private void VelocityControl(float deltaT) {
291293
} else if (_fakedTheta < _rotationalLimits.Value.min) {
292294
_fakedTheta = _rotationalLimits.Value.min;
293295
}
294-
295-
float _lastFakedTheta = _fakedTheta;
296-
296+
297+
// Limit theta to specific range
297298
_fakedTheta = Mathf.Clamp(_fakedTheta, -180, 179);
298-
if (_lastFakedTheta == _fakedTheta)
299+
300+
// Check and see if we've hit a hard limit to zero out velocity
301+
if (Math.Abs(lastFakedTheta - _fakedTheta) < 0.001f)
299302
_lastVel = 0;
300303

301304
_jointA.limits =

engine/Assets/Scripts/Importer/Importer.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,8 @@ void WheelJoint() {
210210
mat.dynamicFriction = 0f;
211211
mat.staticFriction = 0f;
212212
mat.frictionCombine = PhysicMaterialCombine.Multiply;
213+
mat.bounceCombine = PhysicMaterialCombine.Multiply;
214+
mat.bounciness = 0f;
213215
});
214216

215217
var wheelA = gameObjectA.AddComponent<FixedJoint>();

engine/Assets/Scripts/UI/Dynamic/Modals/Configuring/ConfigJointModal.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
using Synthesis;
66
using Utilities.ColorManager;
77
using Synthesis.PreferenceManager;
8-
using System.Data.SqlTypes;
98

109
public class ConfigJointModal : ModalDynamic {
1110
const float MODAL_HEIGHT = 500f;
@@ -195,7 +194,7 @@ public override void Update() {}
195194

196195
public override void Delete() {}
197196

198-
private void CreateEntry(string name, float currAcc, float currVel, Boolean includeAcc, Action<float> onAcc, Action<float> onVel,
197+
private void CreateEntry(string name, float currAcc, float currVel, bool includeAcc, Action<float> onAcc, Action<float> onVel,
199198
string velUnits = "RPM") {
200199
Content entry =
201200
_scrollView.Content.CreateSubContent(new Vector2(_scrollViewWidth - 20, PADDING + PADDING + PADDING + 50f))

0 commit comments

Comments
 (0)