forked from cgvr/DeltaVR
deltavr multiplayer 2.0
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
namespace UnityEngine.XR.Content.Interaction
|
||||
{
|
||||
/// <summary>
|
||||
/// Apply forward force to instantiated prefab
|
||||
/// </summary>
|
||||
public class LaunchProjectile : MonoBehaviour
|
||||
{
|
||||
[SerializeField]
|
||||
[Tooltip("The projectile that's created")]
|
||||
GameObject m_ProjectilePrefab = null;
|
||||
|
||||
[SerializeField]
|
||||
[Tooltip("The point that the project is created")]
|
||||
Transform m_StartPoint = null;
|
||||
|
||||
[SerializeField]
|
||||
[Tooltip("The speed at which the projectile is launched")]
|
||||
float m_LaunchSpeed = 1.0f;
|
||||
|
||||
public void Fire()
|
||||
{
|
||||
GameObject newObject = Instantiate(m_ProjectilePrefab, m_StartPoint.position, m_StartPoint.rotation, null);
|
||||
|
||||
if (newObject.TryGetComponent(out Rigidbody rigidBody))
|
||||
ApplyForce(rigidBody);
|
||||
}
|
||||
|
||||
void ApplyForce(Rigidbody rigidBody)
|
||||
{
|
||||
Vector3 force = m_StartPoint.forward * m_LaunchSpeed;
|
||||
rigidBody.AddForce(force);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 623c5848030e9674893bb3bb376834b8
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user