Skip to content

Commit

Permalink
Add rotating rocks, start importing OpenVR for SteamVR support
Browse files Browse the repository at this point in the history
  • Loading branch information
plaidpants committed Feb 22, 2022
1 parent 56ffb33 commit 0dd148f
Show file tree
Hide file tree
Showing 26 changed files with 287 additions and 12 deletions.
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ Debug/
Build/
BuildAndroid/
BuildWindows/
BuildWindowsVR/
BuildMac/

# ===================================== #
# Visual Studio / MonoDevelop generated #
Expand Down Expand Up @@ -74,4 +76,5 @@ Assets/OVR
Assets/Draw Call Minimizer
Assets/VolumetricLines
Assets/Moon Landscape
Assets/ML-Agents
Assets/ML-Agents
Assets/SteamVR
Binary file modified Assets/Resources/OculusPlatformSettings.asset
Binary file not shown.
42 changes: 31 additions & 11 deletions Assets/RockSphere.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ public class RockSphere : NetworkBehaviour
static public int currentRocks = 0; // number of rocks currently active
static public int totalRocks = 0; // number of rocks currently active plus subsequent rocks
static public int destroyedRocks = 0; // number of rocks destoryed
Rigidbody rb;
public float rotationSpeed;
float currentRotationSpeed;

[ClientRpc]
void rpcSetRockStats(int current, int total, int destroyed)
Expand All @@ -47,37 +50,48 @@ public override void OnStartServer()
base.OnStartServer();

// only do the final rock positioning for the rock on the server use syncvars to sync with the clients


// Find the rock child object
rock = transform.Find("Rock.old").gameObject;

// get the current radius and position from parent gameobject
radius = transform.position.magnitude;
pos = transform.position;

// get the current rotation from the parent position
rot = Quaternion.FromToRotation(Vector3.forward, pos);
transform.rotation = Quaternion.FromToRotation(Vector3.forward, transform.position);

// reset the parent gameobject position back to the center
transform.position = Vector3.zero;
transform.rotation = Quaternion.identity;
//transform.rotation = Quaternion.identity;

// move the child rock to original location and rotation
rock = transform.Find("Rock.old").gameObject;
rock.transform.localPosition = pos;
rock.transform.localRotation = rot;
// Move rock child gameobject out to radius in local coords
pos = rock.transform.localPosition = Vector3.forward * radius;

// rotations is handled by the parent
rot = rock.transform.localRotation = Quaternion.identity;

// Move rock child gameobject out to radius
//rock.transform.position = Vector3.forward * radius;
//rock.transform.rotation = Quaternion.FromToRotation(Vector3.forward, rocket.transform.position);

// apply some rotational torque to the parent gameobject object with the rock attached as a child
Rigidbody rb = GetComponent<Rigidbody>();
rb = GetComponent<Rigidbody>();

Vector3 torque = Random.onUnitSphere * (Random.Range(minSpeed, maxSpeed) / radius);
// ???? note this could be pointing right at us or away so no torque would be added need to catch this and get a new torque
rb.AddTorque(Vector3.Cross(torque, pos.normalized));
rb.AddTorque(Vector3.Cross(torque, rock.transform.position.normalized));

// add some rotation to the rock
//rb.AddTorque(new Vector3(0,10,0));
//float rotation = Random.Range(minRotationSpeed, maxRotationSpeed);
//rb.AddTorque(transform.forward * 100);

totalRocks++;
currentRocks++;

// Debug.Log("OnStartServer current rocks " + currentRocks + " Rocks " + currentRocks + " total " + totalRocks + " destoyed " + destroyedRocks);
rpcSetRockStats(currentRocks, totalRocks, destroyedRocks);

currentRotationSpeed = Random.Range(-rotationSpeed, rotationSpeed);
}

void Start()
Expand Down Expand Up @@ -151,5 +165,11 @@ void OnTriggerEnter(Collider other)
// Update is called once per frame
void Update ()
{
if (!isServer) return;

if (!rb) return;

Quaternion turn = Quaternion.Euler(0f, 0f, currentRotationSpeed * Time.deltaTime);
rb.MoveRotation(rb.rotation * turn);
}
}
Binary file modified Assets/RockSphere1.prefab
Binary file not shown.
Binary file modified Assets/RockSphere1easy.prefab
Binary file not shown.
Binary file modified Assets/RockSphere1hard.prefab
Binary file not shown.
Binary file modified Assets/RockSphere1training.prefab
Binary file not shown.
Binary file modified Assets/RockSphere2.prefab
Binary file not shown.
Binary file modified Assets/RockSphere2easy.prefab
Binary file not shown.
Binary file modified Assets/RockSphere2hard.prefab
Binary file not shown.
Binary file modified Assets/RockSphere3.prefab
Binary file not shown.
Binary file modified Assets/RockSphere3easy.prefab
Binary file not shown.
Binary file modified Assets/RockSphere3hard.prefab
Binary file not shown.
Binary file added Assets/Screenshot_hero.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
92 changes: 92 additions & 0 deletions Assets/Screenshot_hero.png.meta

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

Binary file added Assets/Screenshot_icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
92 changes: 92 additions & 0 deletions Assets/Screenshot_icon.png.meta

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

3 changes: 3 additions & 0 deletions Packages/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@
"com.unity.ugui": "1.0.0",
"com.unity.xr.management": "4.2.1",
"com.unity.xr.oculus": "1.11.2",
"com.unity.xr.openvr.standalone": "2.0.5",
"com.unity.xr.windowsmr": "2.9.2",
"com.valvesoftware.unity.openvr": "file:C:/Users/Jim/Downloads/com.valvesoftware.unity.openvr-1.1.4.tgz",
"com.unity.modules.ai": "1.0.0",
"com.unity.modules.androidjni": "1.0.0",
"com.unity.modules.animation": "1.0.0",
Expand Down
49 changes: 49 additions & 0 deletions Packages/packages-lock.json
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,24 @@
"com.unity.modules.imgui": "1.0.0"
}
},
"com.unity.xr.arsubsystems": {
"version": "2.1.19",
"depth": 1,
"source": "registry",
"dependencies": {
"com.unity.subsystemregistration": "1.0.6"
},
"url": "https://packages.unity.com"
},
"com.unity.xr.interactionsubsystems": {
"version": "1.0.1",
"depth": 1,
"source": "registry",
"dependencies": {
"com.unity.subsystemregistration": "1.0.5"
},
"url": "https://packages.unity.com"
},
"com.unity.xr.legacyinputhelpers": {
"version": "2.1.8",
"depth": 1,
Expand Down Expand Up @@ -164,6 +182,37 @@
},
"url": "https://packages.unity.com"
},
"com.unity.xr.openvr.standalone": {
"version": "2.0.5",
"depth": 0,
"source": "registry",
"dependencies": {},
"url": "https://packages.unity.com"
},
"com.unity.xr.windowsmr": {
"version": "2.9.2",
"depth": 0,
"source": "registry",
"dependencies": {
"com.unity.modules.subsystems": "1.0.0",
"com.unity.modules.vr": "1.0.0",
"com.unity.modules.xr": "1.0.0",
"com.unity.xr.management": "4.0.1",
"com.unity.xr.interactionsubsystems": "1.0.1",
"com.unity.xr.arsubsystems": "2.1.3"
},
"url": "https://packages.unity.com"
},
"com.valvesoftware.unity.openvr": {
"version": "file:C:/Users/Jim/Downloads/com.valvesoftware.unity.openvr-1.1.4.tgz",
"depth": 0,
"source": "local-tarball",
"dependencies": {
"com.unity.xr.management": "3.2.13",
"com.unity.ugui": "1.0.0",
"com.unity.xr.legacyinputhelpers": "2.1.4"
}
},
"com.unity.modules.ai": {
"version": "1.0.0",
"depth": 0,
Expand Down
Binary file modified ProjectSettings/AudioManager.asset
Binary file not shown.
16 changes: 16 additions & 0 deletions ProjectSettings/BurstAotSettings_StandaloneOSX.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"MonoBehaviour": {
"Version": 4,
"EnableBurstCompilation": true,
"EnableOptimisations": true,
"EnableSafetyChecks": false,
"EnableDebugInAllBuilds": false,
"UsePlatformSDKLinker": false,
"CpuMinTargetX32": 0,
"CpuMaxTargetX32": 0,
"CpuMinTargetX64": 0,
"CpuMaxTargetX64": 0,
"CpuTargetsX64": 72,
"OptimizeFor": 0
}
}
Binary file modified ProjectSettings/EditorBuildSettings.asset
Binary file not shown.
Binary file modified ProjectSettings/GraphicsSettings.asset
Binary file not shown.
Binary file modified ProjectSettings/ProjectSettings.asset
Binary file not shown.
Binary file modified ProjectSettings/QualitySettings.asset
Binary file not shown.
Binary file modified ProjectSettings/UnityConnectSettings.asset
Binary file not shown.

0 comments on commit 0dd148f

Please sign in to comment.