forked from svenberra/NewtonUnityPlugin
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
correct bugs with default damping and Inertia settings
based on ee38fae * added missing damping stuffs to make the damping value changes effective (copycat Newtonbody.cs of version f182340) * added 1 option toggle to set the inertia and CoM from the editor OR to calculate them from the collider (see dNewtonBody::SetCenterOfMass in dNewtonBody.cpp) Works with Newton Dynamics from Jan 2, 2018(7e379d7)
- Loading branch information
Showing
17 changed files
with
1,006 additions
and
982 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,56 +1,56 @@ | ||
using System.Collections; | ||
using System.Collections.Generic; | ||
using UnityEngine; | ||
|
||
public class PlayerDriver : MonoBehaviour | ||
{ | ||
|
||
// Use this for initialization | ||
void Start () | ||
{ | ||
motor = transform.Find("motor").GetComponent<NewtonBody>(); | ||
motorJoint = transform.Find("motor").GetComponent<NewtonDoubleHingeActuator>(); | ||
} | ||
|
||
// Update is called once per frame | ||
void Update () | ||
{ | ||
if (motorJoint != null) | ||
{ | ||
// control forward and backwoar movement | ||
if (Input.GetKey(KeyCode.W)) | ||
{ | ||
motor.SleepState = false; | ||
motorJoint.TargetAngle1 = 1e10f; | ||
} | ||
else if (Input.GetKey(KeyCode.S)) | ||
{ | ||
motor.SleepState = false; | ||
motorJoint.TargetAngle1 = -1e10f; | ||
} | ||
else | ||
{ | ||
motorJoint.TargetAngle1 = motorJoint.GetJointAngle1(); | ||
} | ||
|
||
// control steering movement | ||
if (Input.GetKey(KeyCode.A)) | ||
{ | ||
motor.SleepState = false; | ||
motorJoint.TargetAngle0 = 1e10f; | ||
} | ||
else if (Input.GetKey(KeyCode.D)) | ||
{ | ||
motor.SleepState = false; | ||
motorJoint.TargetAngle0 = -1e10f; | ||
} | ||
else | ||
{ | ||
motorJoint.TargetAngle0 = motorJoint.GetJointAngle0(); | ||
} | ||
} | ||
} | ||
|
||
NewtonBody motor = null; | ||
NewtonDoubleHingeActuator motorJoint = null; | ||
} | ||
using System.Collections; | ||
using System.Collections.Generic; | ||
using UnityEngine; | ||
|
||
public class PlayerDriver : MonoBehaviour | ||
{ | ||
|
||
// Use this for initialization | ||
void Start () | ||
{ | ||
motor = transform.Find("motor").GetComponent<NewtonBody>(); | ||
motorJoint = transform.Find("motor").GetComponent<NewtonUniversalActuator>(); | ||
} | ||
|
||
// Update is called once per frame | ||
void Update () | ||
{ | ||
if (motorJoint != null) | ||
{ | ||
// control forward and backwoar movement | ||
if (Input.GetKey(KeyCode.W)) | ||
{ | ||
motor.SleepState = false; | ||
motorJoint.TargetAngle1 = 1e10f; | ||
} | ||
else if (Input.GetKey(KeyCode.S)) | ||
{ | ||
motor.SleepState = false; | ||
motorJoint.TargetAngle1 = -1e10f; | ||
} | ||
else | ||
{ | ||
motorJoint.TargetAngle1 = motorJoint.GetJointAngle1(); | ||
} | ||
|
||
// control steering movement | ||
if (Input.GetKey(KeyCode.A)) | ||
{ | ||
motor.SleepState = false; | ||
motorJoint.TargetAngle0 = 1e10f; | ||
} | ||
else if (Input.GetKey(KeyCode.D)) | ||
{ | ||
motor.SleepState = false; | ||
motorJoint.TargetAngle0 = -1e10f; | ||
} | ||
else | ||
{ | ||
motorJoint.TargetAngle0 = motorJoint.GetJointAngle0(); | ||
} | ||
} | ||
} | ||
|
||
NewtonBody motor = null; | ||
NewtonUniversalActuator motorJoint = null; | ||
} |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.