Skip to content

Commit

Permalink
0.2.5e2
Browse files Browse the repository at this point in the history
Ressetting doesn't flip out.
  • Loading branch information
griffinteller committed May 2, 2020
1 parent 8147909 commit 8d38838
Show file tree
Hide file tree
Showing 89 changed files with 510 additions and 21,794 deletions.
13 changes: 13 additions & 0 deletions Assets/Scripts/Main/.idea/.idea.Main.dir/.idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions Assets/Scripts/Main/.idea/.idea.Main.dir/.idea/encodings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions Assets/Scripts/Main/.idea/.idea.Main.dir/.idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions Assets/Scripts/Main/.idea/.idea.Main.dir/.idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions Assets/Scripts/Main/.idea/.idea.Main.dir/riderModule.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

47 changes: 37 additions & 10 deletions Assets/Scripts/Main/ActionHandler.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Collections.Generic;
using System;
using System.Collections.Generic;
using Networking;
using Photon.Pun;
using UnityEngine;
Expand Down Expand Up @@ -58,6 +59,16 @@ private void Start()

public void Update()
{

foreach (var wheelCollider in _wheelColliders)
{

Debug.Log(wheelCollider.motorTorque);
Debug.Log(wheelCollider.brakeTorque);
Debug.Log(wheelCollider.rpm);

}

switch (_resetState)
{
case ResetState.NeedToReset:
Expand Down Expand Up @@ -97,9 +108,7 @@ private void InternalResetRobot()

robotBody.transform.localPosition = Vector3.zero;
robotBody.transform.localRotation = Quaternion.identity;

robotBody.transform.localRotation = Quaternion.identity;


_rigidbody.velocity = Vector3.zero;
_rigidbody.angularVelocity = Vector3.zero;
_rigidbody.isKinematic = true;
Expand All @@ -108,8 +117,8 @@ private void InternalResetRobot()
{
wheelCollider.motorTorque = 0;
wheelCollider.steerAngle = 0;
wheelCollider.brakeTorque = Mathf.Infinity;
CachedFind(wheelCollider.name = "Vis").transform.localRotation = Quaternion.identity;
wheelCollider.brakeTorque = 10000;
CachedFind(wheelCollider.name + "Vis").transform.localRotation = Quaternion.identity;
}
}

Expand Down Expand Up @@ -144,12 +153,30 @@ public void InvertTires()
}
}

public void SetTireSteering(string tireName, float bering)
public void SetTireSteering(string tireName, float bearing)
{
var tireObject = CachedFind(tireName);
tireObject.GetComponent<WheelCollider>().steerAngle = internalNegation * bering;
CachedFind(tireName + "Vis").transform.localRotation = Quaternion.Euler(
0, bering, 0);

var wheelCollider = tireObject.GetComponent<WheelCollider>();

wheelCollider.steerAngle = internalNegation * bearing;

var tireMeshParent = CachedFind(tireName + "Vis");

var currentLocalRight = tireMeshParent.transform.localRotation
* Vector3.right;

var currentBearing = Mathf.Rad2Deg * Mathf.Acos(currentLocalRight.x);

if (currentLocalRight.z > 0)
currentBearing *= -1;

tireMeshParent.transform.Rotate(
robotBody.transform.up,
bearing - currentBearing,
Space.World);


}

public void OnDestroy()
Expand Down
15 changes: 14 additions & 1 deletion Assets/Scripts/Main/RobotStateSender.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,22 @@ public class RobotStateSender : MonoBehaviour
{

var rssCast = (RobotStateSender) rss;

while (true)
{
try
{
rssCast._clientStream = new FileStream("/tmp/" + PipeName, FileMode.Open, FileAccess.Write);
break;
}
catch (IOException)
{
continue;
}
}

rssCast._clientStream = File.OpenWrite("/tmp/" + PipeName);
rssCast._connected = true;
Debug.Log("RSS Connected!");

};

Expand Down
9 changes: 4 additions & 5 deletions Assets/Scripts/Main/TireAnimation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,14 @@ namespace Main
public class TireAnimation : MonoBehaviour
{
private ActionHandler _actionHandler;

public float lerpSpeed;
public Transform robot;


public Transform wheelColliderParent;
//private Dictionary<string, WheelCollider> _wheelCollidersDictionary;


public void Start()
{
_actionHandler = transform.parent.parent.parent.GetComponent<ActionHandler>();
Expand All @@ -29,9 +30,7 @@ public void Update()
tireMeshParent.Rotate(tireMeshParent.right,
wheelCollider.rpm * _actionHandler.internalNegation / 60 * 360 * Time.deltaTime, Space.World);

// TODO: have tire meshes sync up with collider rotation directly, to prevent them from becoming out of sync

var lerper = tireMeshParent.GetComponent<Lerper>();
/*var lerper = tireMeshParent.GetComponent<Lerper>();
if (lerper.lerping) return;
Expand All @@ -40,7 +39,7 @@ public void Update()
if (robot.up.y > 0)
tireMeshParent.position = pos;
else
lerper.LerpLocal(transform.parent.InverseTransformPoint(pos), lerpSpeed);
lerper.LerpLocal(transform.parent.InverseTransformPoint(pos), lerpSpeed);*/
}
}
}
Expand Down
33 changes: 23 additions & 10 deletions Assets/Scripts/Main/UserScriptInterpreter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -113,9 +113,23 @@ public class UserScriptInterpreter : MonoBehaviour

var usiCast = (UserScriptInterpreter) usi;

usiCast._clientStream = File.OpenRead("/tmp/" + PipeName);
usiCast._clientStream.ReadTimeout = PosixReadTimeout;
while (true)
{
try
{
usiCast._clientStream = new FileStream("/tmp/" + PipeName, FileMode.Open, FileAccess.Read);
break;
}
catch (IOException)
{
continue;
}
}

usiCast._clientReader = new StreamReader(usiCast._clientStream);

usiCast._connected = true;
Debug.Log("USI Connected!");


};
Expand Down Expand Up @@ -158,27 +172,26 @@ public void Update()

private void InitStreams()
{

switch (_platform)
{

case SimplePlatform.Windows:

_clientStream = new NamedPipeClientStream(PipeName);
_clientReader = new StreamReader(_clientStream);
break;

case SimplePlatform.Posix:

Task.Factory.StartNew(ConnectToPipePosix, this);
break;

default:

throw new NotImplementedException();

}

_clientReader = new StreamReader(_clientStream);

}

Expand Down
2 changes: 1 addition & 1 deletion Packages/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"dependencies": {
"com.unity.2d.sprite": "1.0.0",
"com.unity.collab-proxy": "1.2.16",
"com.unity.ide.rider": "1.1.4",
"com.unity.ide.rider": "2.0.2",
"com.unity.ide.vscode": "1.1.4",
"com.unity.inputsystem": "1.0.0-preview.6",
"com.unity.multiplayer-hlapi": "1.0.4",
Expand Down
2 changes: 1 addition & 1 deletion ProjectSettings/ProjectSettings.asset
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ PlayerSettings:
16:10: 1
16:9: 1
Others: 1
bundleVersion: 0.2.5e1
bundleVersion: 0.2.5e2
preloadedAssets:
- {fileID: 0}
- {fileID: 0}
Expand Down
2 changes: 1 addition & 1 deletion ProjectSettings/QualitySettings.asset
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
QualitySettings:
m_ObjectHideFlags: 0
serializedVersion: 5
m_CurrentQuality: 2
m_CurrentQuality: 0
m_QualitySettings:
- serializedVersion: 2
name: Very Low
Expand Down
Loading

0 comments on commit 8d38838

Please sign in to comment.