fishbait/UnityProject/Assets/Tanks/Scripts/Projectile.cs
NIMFER bf403a8f97 Ducktaped together a FishNet version of the Transport
Ducktaped together a FishNet version of the Transport, now I need to edit the LoadBalancer and Server so it connects and actually trades information
2022-08-14 03:55:25 +02:00

34 lines
858 B
C#

using FishNet.Object;
using UnityEngine;
namespace FishNet.Examples.Tanks
{
public class Projectile : NetworkBehaviour
{
public float destroyAfter = 5;
public Rigidbody rigidBody;
public float force = 1000;
// set velocity for server and client. this way we don't have to sync the
// position, because both the server and the client simulate it.
void Start()
{
rigidBody.AddForce(transform.forward * force);
}
// destroy for everyone on the server
[Server]
void DestroySelf()
{
Despawn(gameObject);
}
// ServerCallback because we don't want a warning if OnTriggerEnter is
// called on the client
void OnTriggerEnter(Collider co)
{
Despawn(gameObject);
}
}
}