Somewhat working gun

pull/1/head
marcgauch 2023-12-07 21:35:13 +01:00
parent 2bb523a893
commit aeae3c0d19
4 changed files with 270 additions and 150 deletions

View File

@ -24,10 +24,10 @@ Transform:
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1833753722200232641}
serializedVersion: 2
m_LocalRotation: {x: 0.19641057, y: -0.08320766, z: -0.05917528, w: 0.9751911}
m_LocalRotation: {x: 0.09445323, y: -0.09285291, z: -0.0706375, w: 0.98866946}
m_LocalPosition: {x: 0.0161, y: -0.0496, z: -0.0459}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 0}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_LocalEulerAnglesHint: {x: 10, y: -11.536, z: -9.186}

View File

@ -17,7 +17,7 @@ MonoBehaviour:
handTrackingSupport: 1
handTrackingFrequency: 1
handTrackingVersion: 2
multimodalHandsControllersSupport: 0
multimodalHandsControllersSupport: 1
anchorSupport: 1
sharedAnchorSupport: 0
renderModelSupport: 0

View File

@ -137,39 +137,39 @@ PrefabInstance:
objectReference: {fileID: 0}
- target: {fileID: 4453513310108136, guid: 835e735ca71bf78459fb2cababd74112, type: 3}
propertyPath: m_LocalPosition.x
value: 0
value: -0.04
objectReference: {fileID: 0}
- target: {fileID: 4453513310108136, guid: 835e735ca71bf78459fb2cababd74112, type: 3}
propertyPath: m_LocalPosition.y
value: 0
value: -0.04
objectReference: {fileID: 0}
- target: {fileID: 4453513310108136, guid: 835e735ca71bf78459fb2cababd74112, type: 3}
propertyPath: m_LocalPosition.z
value: 0
value: -0.11
objectReference: {fileID: 0}
- target: {fileID: 4453513310108136, guid: 835e735ca71bf78459fb2cababd74112, type: 3}
propertyPath: m_LocalRotation.w
value: 1
value: 0.5
objectReference: {fileID: 0}
- target: {fileID: 4453513310108136, guid: 835e735ca71bf78459fb2cababd74112, type: 3}
propertyPath: m_LocalRotation.x
value: 0
value: -0.5
objectReference: {fileID: 0}
- target: {fileID: 4453513310108136, guid: 835e735ca71bf78459fb2cababd74112, type: 3}
propertyPath: m_LocalRotation.y
value: 0
value: -0.5
objectReference: {fileID: 0}
- target: {fileID: 4453513310108136, guid: 835e735ca71bf78459fb2cababd74112, type: 3}
propertyPath: m_LocalRotation.z
value: 0
value: -0.5
objectReference: {fileID: 0}
- target: {fileID: 4453513310108136, guid: 835e735ca71bf78459fb2cababd74112, type: 3}
propertyPath: m_LocalEulerAnglesHint.x
value: 0
value: -90
objectReference: {fileID: 0}
- target: {fileID: 4453513310108136, guid: 835e735ca71bf78459fb2cababd74112, type: 3}
propertyPath: m_LocalEulerAnglesHint.y
value: 0
value: -90
objectReference: {fileID: 0}
- target: {fileID: 4453513310108136, guid: 835e735ca71bf78459fb2cababd74112, type: 3}
propertyPath: m_LocalEulerAnglesHint.z
@ -179,6 +179,10 @@ PrefabInstance:
propertyPath: m_Enabled
value: 1
objectReference: {fileID: 0}
- target: {fileID: 114428879332287356, guid: 835e735ca71bf78459fb2cababd74112, type: 3}
propertyPath: m_showState
value: 2
objectReference: {fileID: 0}
- target: {fileID: 114567484643301796, guid: 835e735ca71bf78459fb2cababd74112, type: 3}
propertyPath: _enablePhysicsCapsules
value: 1
@ -1199,7 +1203,44 @@ PrefabInstance:
m_AddedGameObjects: []
m_AddedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: 2e0c303eba3dd9ff98017eff31e6159f, type: 3}
--- !u!1001 &681042490
--- !u!1 &763350377
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 763350378}
m_Layer: 0
m_Name: LeftControllerInHandAnchor
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &763350378
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 763350377}
serializedVersion: 2
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children:
- {fileID: 493291595}
m_Father: {fileID: 1368183235}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!4 &782628376 stripped
Transform:
m_CorrespondingSourceObject: {fileID: 4453513310108136, guid: 835e735ca71bf78459fb2cababd74112, type: 3}
m_PrefabInstance: {fileID: 1939419979}
m_PrefabAsset: {fileID: 0}
--- !u!1001 &1039411707
PrefabInstance:
m_ObjectHideFlags: 0
serializedVersion: 2
@ -1211,6 +1252,10 @@ PrefabInstance:
propertyPath: m_Name
value: OVRControllerPrefab
objectReference: {fileID: 0}
- target: {fileID: 112276, guid: d9809c5e8418bb047bf2c8ba1d1a2cec, type: 3}
propertyPath: m_IsActive
value: 0
objectReference: {fileID: 0}
- target: {fileID: 488160, guid: d9809c5e8418bb047bf2c8ba1d1a2cec, type: 3}
propertyPath: m_LocalPosition.x
value: 0
@ -1260,43 +1305,11 @@ PrefabInstance:
m_AddedGameObjects: []
m_AddedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: d9809c5e8418bb047bf2c8ba1d1a2cec, type: 3}
--- !u!4 &681042491 stripped
--- !u!4 &1039411708 stripped
Transform:
m_CorrespondingSourceObject: {fileID: 488160, guid: d9809c5e8418bb047bf2c8ba1d1a2cec, type: 3}
m_PrefabInstance: {fileID: 681042490}
m_PrefabInstance: {fileID: 1039411707}
m_PrefabAsset: {fileID: 0}
--- !u!1 &763350377
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 763350378}
m_Layer: 0
m_Name: LeftControllerInHandAnchor
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &763350378
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 763350377}
serializedVersion: 2
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children:
- {fileID: 493291595}
m_Father: {fileID: 1368183235}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1001 &1095568620
PrefabInstance:
m_ObjectHideFlags: 0
@ -1531,100 +1544,6 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 9067480af55f5874d8f613b16812f968, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!1001 &1309333584
PrefabInstance:
m_ObjectHideFlags: 0
serializedVersion: 2
m_Modification:
serializedVersion: 3
m_TransformParent: {fileID: 1368183234}
m_Modifications:
- target: {fileID: 1870938896605422, guid: 835e735ca71bf78459fb2cababd74112, type: 3}
propertyPath: m_Name
value: OVRHandPrefab
objectReference: {fileID: 0}
- target: {fileID: 4453513310108136, guid: 835e735ca71bf78459fb2cababd74112, type: 3}
propertyPath: m_LocalPosition.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 4453513310108136, guid: 835e735ca71bf78459fb2cababd74112, type: 3}
propertyPath: m_LocalPosition.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 4453513310108136, guid: 835e735ca71bf78459fb2cababd74112, type: 3}
propertyPath: m_LocalPosition.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 4453513310108136, guid: 835e735ca71bf78459fb2cababd74112, type: 3}
propertyPath: m_LocalRotation.w
value: 1
objectReference: {fileID: 0}
- target: {fileID: 4453513310108136, guid: 835e735ca71bf78459fb2cababd74112, type: 3}
propertyPath: m_LocalRotation.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 4453513310108136, guid: 835e735ca71bf78459fb2cababd74112, type: 3}
propertyPath: m_LocalRotation.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 4453513310108136, guid: 835e735ca71bf78459fb2cababd74112, type: 3}
propertyPath: m_LocalRotation.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 4453513310108136, guid: 835e735ca71bf78459fb2cababd74112, type: 3}
propertyPath: m_LocalEulerAnglesHint.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 4453513310108136, guid: 835e735ca71bf78459fb2cababd74112, type: 3}
propertyPath: m_LocalEulerAnglesHint.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 4453513310108136, guid: 835e735ca71bf78459fb2cababd74112, type: 3}
propertyPath: m_LocalEulerAnglesHint.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 114252240061623322, guid: 835e735ca71bf78459fb2cababd74112, type: 3}
propertyPath: m_Enabled
value: 1
objectReference: {fileID: 0}
- target: {fileID: 114392993255165844, guid: 835e735ca71bf78459fb2cababd74112, type: 3}
propertyPath: m_Enabled
value: 0
objectReference: {fileID: 0}
- target: {fileID: 114428879332287356, guid: 835e735ca71bf78459fb2cababd74112, type: 3}
propertyPath: HandType
value: 1
objectReference: {fileID: 0}
- target: {fileID: 114567484643301796, guid: 835e735ca71bf78459fb2cababd74112, type: 3}
propertyPath: _skeletonType
value: 1
objectReference: {fileID: 0}
- target: {fileID: 114567484643301796, guid: 835e735ca71bf78459fb2cababd74112, type: 3}
propertyPath: _enablePhysicsCapsules
value: 1
objectReference: {fileID: 0}
- target: {fileID: 114925265787909616, guid: 835e735ca71bf78459fb2cababd74112, type: 3}
propertyPath: _meshType
value: 1
objectReference: {fileID: 0}
- target: {fileID: 114925265787909616, guid: 835e735ca71bf78459fb2cababd74112, type: 3}
propertyPath: m_Enabled
value: 1
objectReference: {fileID: 0}
- target: {fileID: 137619227449585070, guid: 835e735ca71bf78459fb2cababd74112, type: 3}
propertyPath: m_Enabled
value: 1
objectReference: {fileID: 0}
m_RemovedComponents: []
m_RemovedGameObjects: []
m_AddedGameObjects: []
m_AddedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: 835e735ca71bf78459fb2cababd74112, type: 3}
--- !u!4 &1309333585 stripped
Transform:
m_CorrespondingSourceObject: {fileID: 4453513310108136, guid: 835e735ca71bf78459fb2cababd74112, type: 3}
m_PrefabInstance: {fileID: 1309333584}
m_PrefabAsset: {fileID: 0}
--- !u!1001 &1368183232
PrefabInstance:
m_ObjectHideFlags: 0
@ -1701,6 +1620,10 @@ PrefabInstance:
propertyPath: isInsightPassthroughEnabled
value: 1
objectReference: {fileID: 0}
- target: {fileID: 11400000, guid: 126d619cf4daa52469682f85c1378b4a, type: 3}
propertyPath: controllerDrivenHandPosesType
value: 2
objectReference: {fileID: 0}
m_RemovedComponents: []
m_RemovedGameObjects: []
m_AddedGameObjects:
@ -1727,10 +1650,10 @@ PrefabInstance:
addedObject: {fileID: 552350707}
- targetCorrespondingSourceObject: {fileID: 487254, guid: 126d619cf4daa52469682f85c1378b4a, type: 3}
insertIndex: -1
addedObject: {fileID: 1309333585}
addedObject: {fileID: 782628376}
- targetCorrespondingSourceObject: {fileID: 4484591312116288, guid: 126d619cf4daa52469682f85c1378b4a, type: 3}
insertIndex: -1
addedObject: {fileID: 681042491}
addedObject: {fileID: 1039411708}
m_AddedComponents:
- targetCorrespondingSourceObject: {fileID: 100004, guid: 126d619cf4daa52469682f85c1378b4a, type: 3}
insertIndex: -1
@ -2297,6 +2220,103 @@ Transform:
m_CorrespondingSourceObject: {fileID: 7601405052768654441, guid: 2e0c303eba3dd9ff98017eff31e6159f, type: 3}
m_PrefabInstance: {fileID: 1400762667}
m_PrefabAsset: {fileID: 0}
--- !u!1001 &1939419979
PrefabInstance:
m_ObjectHideFlags: 0
serializedVersion: 2
m_Modification:
serializedVersion: 3
m_TransformParent: {fileID: 1368183234}
m_Modifications:
- target: {fileID: 1870938896605422, guid: 835e735ca71bf78459fb2cababd74112, type: 3}
propertyPath: m_Name
value: OVRHandPrefab
objectReference: {fileID: 0}
- target: {fileID: 4453513310108136, guid: 835e735ca71bf78459fb2cababd74112, type: 3}
propertyPath: m_LocalPosition.x
value: 0.04
objectReference: {fileID: 0}
- target: {fileID: 4453513310108136, guid: 835e735ca71bf78459fb2cababd74112, type: 3}
propertyPath: m_LocalPosition.y
value: -0.04
objectReference: {fileID: 0}
- target: {fileID: 4453513310108136, guid: 835e735ca71bf78459fb2cababd74112, type: 3}
propertyPath: m_LocalPosition.z
value: -0.11
objectReference: {fileID: 0}
- target: {fileID: 4453513310108136, guid: 835e735ca71bf78459fb2cababd74112, type: 3}
propertyPath: m_LocalRotation.w
value: 0.5
objectReference: {fileID: 0}
- target: {fileID: 4453513310108136, guid: 835e735ca71bf78459fb2cababd74112, type: 3}
propertyPath: m_LocalRotation.x
value: 0.5
objectReference: {fileID: 0}
- target: {fileID: 4453513310108136, guid: 835e735ca71bf78459fb2cababd74112, type: 3}
propertyPath: m_LocalRotation.y
value: 0.5
objectReference: {fileID: 0}
- target: {fileID: 4453513310108136, guid: 835e735ca71bf78459fb2cababd74112, type: 3}
propertyPath: m_LocalRotation.z
value: -0.5
objectReference: {fileID: 0}
- target: {fileID: 4453513310108136, guid: 835e735ca71bf78459fb2cababd74112, type: 3}
propertyPath: m_LocalEulerAnglesHint.x
value: 90
objectReference: {fileID: 0}
- target: {fileID: 4453513310108136, guid: 835e735ca71bf78459fb2cababd74112, type: 3}
propertyPath: m_LocalEulerAnglesHint.y
value: 90
objectReference: {fileID: 0}
- target: {fileID: 4453513310108136, guid: 835e735ca71bf78459fb2cababd74112, type: 3}
propertyPath: m_LocalEulerAnglesHint.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 114252240061623322, guid: 835e735ca71bf78459fb2cababd74112, type: 3}
propertyPath: m_Enabled
value: 1
objectReference: {fileID: 0}
- target: {fileID: 114392993255165844, guid: 835e735ca71bf78459fb2cababd74112, type: 3}
propertyPath: m_Enabled
value: 0
objectReference: {fileID: 0}
- target: {fileID: 114428879332287356, guid: 835e735ca71bf78459fb2cababd74112, type: 3}
propertyPath: HandType
value: 1
objectReference: {fileID: 0}
- target: {fileID: 114428879332287356, guid: 835e735ca71bf78459fb2cababd74112, type: 3}
propertyPath: m_Enabled
value: 1
objectReference: {fileID: 0}
- target: {fileID: 114428879332287356, guid: 835e735ca71bf78459fb2cababd74112, type: 3}
propertyPath: m_showState
value: 2
objectReference: {fileID: 0}
- target: {fileID: 114567484643301796, guid: 835e735ca71bf78459fb2cababd74112, type: 3}
propertyPath: m_Enabled
value: 1
objectReference: {fileID: 0}
- target: {fileID: 114567484643301796, guid: 835e735ca71bf78459fb2cababd74112, type: 3}
propertyPath: _skeletonType
value: 1
objectReference: {fileID: 0}
- target: {fileID: 114925265787909616, guid: 835e735ca71bf78459fb2cababd74112, type: 3}
propertyPath: _meshType
value: 1
objectReference: {fileID: 0}
- target: {fileID: 114925265787909616, guid: 835e735ca71bf78459fb2cababd74112, type: 3}
propertyPath: m_Enabled
value: 1
objectReference: {fileID: 0}
- target: {fileID: 137619227449585070, guid: 835e735ca71bf78459fb2cababd74112, type: 3}
propertyPath: m_Enabled
value: 1
objectReference: {fileID: 0}
m_RemovedComponents: []
m_RemovedGameObjects: []
m_AddedGameObjects: []
m_AddedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: 835e735ca71bf78459fb2cababd74112, type: 3}
--- !u!1001 &1974199063
PrefabInstance:
m_ObjectHideFlags: 0
@ -2433,6 +2453,9 @@ PrefabInstance:
- targetCorrespondingSourceObject: {fileID: 2867417286392604782, guid: 37e98970f8baf7647b735d9036006f0d, type: 3}
insertIndex: -1
addedObject: {fileID: 2106522551}
- targetCorrespondingSourceObject: {fileID: 2867417286392604782, guid: 37e98970f8baf7647b735d9036006f0d, type: 3}
insertIndex: -1
addedObject: {fileID: 2106522557}
m_SourcePrefab: {fileID: 100100000, guid: 37e98970f8baf7647b735d9036006f0d, type: 3}
--- !u!1 &2106522549 stripped
GameObject:
@ -2465,6 +2488,102 @@ MonoBehaviour:
simpleShoot: {fileID: 2106522550}
shootButton: 2097152
offset: {fileID: 4049662313537657896, guid: 8a7053ae412b1e82cbcc329ce7967f8e, type: 3}
--- !u!82 &2106522557
AudioSource:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2106522549}
m_Enabled: 1
serializedVersion: 4
OutputAudioMixerGroup: {fileID: 0}
m_audioClip: {fileID: 8300000, guid: 799887af54a4449ad9e4d22723971db5, type: 3}
m_PlayOnAwake: 0
m_Volume: 1
m_Pitch: 1
Loop: 0
Mute: 0
Spatialize: 0
SpatializePostEffects: 0
Priority: 128
DopplerLevel: 1
MinDistance: 1
MaxDistance: 500
Pan2D: 0
rolloffMode: 0
BypassEffects: 0
BypassListenerEffects: 0
BypassReverbZones: 0
rolloffCustomCurve:
serializedVersion: 2
m_Curve:
- serializedVersion: 3
time: 0
value: 1
inSlope: 0
outSlope: 0
tangentMode: 0
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
- serializedVersion: 3
time: 1
value: 0
inSlope: 0
outSlope: 0
tangentMode: 0
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
panLevelCustomCurve:
serializedVersion: 2
m_Curve:
- serializedVersion: 3
time: 0
value: 0
inSlope: 0
outSlope: 0
tangentMode: 0
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
spreadCustomCurve:
serializedVersion: 2
m_Curve:
- serializedVersion: 3
time: 0
value: 0
inSlope: 0
outSlope: 0
tangentMode: 0
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
reverbZoneMixCustomCurve:
serializedVersion: 2
m_Curve:
- serializedVersion: 3
time: 0
value: 1
inSlope: 0
outSlope: 0
tangentMode: 0
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
--- !u!1660057539 &9223372036854775807
SceneRoots:
m_ObjectHideFlags: 0

View File

@ -3,9 +3,7 @@ using System.Collections.Generic;
using UnityEngine;
public class iamagun : MonoBehaviour
{
public SimpleShoot simpleShoot;
public OVRInput.Button shootButton;
@ -13,14 +11,16 @@ public class iamagun : MonoBehaviour
private AudioSource audio;
private Vector3 offsetPosition;
private Quaternion offsetRotation;
// Start is called before the first frame update
void Start()
{
audio = GetComponent<AudioSource>();
// Pre-calculate the offset position based on the offset transform
// Pre-calculate the offset position and rotation based on the offset transform
offsetPosition = offset.position;
offsetRotation = offset.rotation;
}
// Update is called once per frame
@ -32,12 +32,13 @@ public class iamagun : MonoBehaviour
Vector3 controllerLocalPosition = OVRInput.GetLocalControllerPosition(OVRInput.Controller.RTouch);
Quaternion controllerLocalRotation = OVRInput.GetLocalControllerRotation(OVRInput.Controller.RTouch);
// Apply the pre-calculated offset position to the local position
// Apply the pre-calculated offset position and rotation to the local position and rotation
Vector3 finalPosition = controllerLocalPosition + controllerLocalRotation * offsetPosition;
transform.position = finalPosition;
Quaternion finalRotation = controllerLocalRotation * offsetRotation;
// Set the cube's rotation to match the controller's rotation
transform.rotation = controllerLocalRotation;
// Set the gun's position and rotation
transform.position = finalPosition;
transform.rotation = finalRotation;
}
if (OVRInput.GetDown(shootButton))