mirror of
https://github.com/MirrorNetworking/Mirror.git
synced 2024-11-18 11:00:32 +00:00
tanks example namespaces updated
This commit is contained in:
parent
c5b4211ac7
commit
227b0a71d1
@ -1,36 +1,38 @@
|
|||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using Mirror;
|
|
||||||
|
|
||||||
public class Projectile : NetworkBehaviour
|
namespace Mirror.Examples.Tanks
|
||||||
{
|
{
|
||||||
public float destroyAfter = 5;
|
public class Projectile : NetworkBehaviour
|
||||||
public Rigidbody rigidBody;
|
|
||||||
public float force = 1000;
|
|
||||||
|
|
||||||
public override void OnStartServer()
|
|
||||||
{
|
{
|
||||||
Invoke(nameof(DestroySelf), destroyAfter);
|
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
|
public override void OnStartServer()
|
||||||
// position, because both the server and the client simulate it.
|
{
|
||||||
void Start()
|
Invoke(nameof(DestroySelf), destroyAfter);
|
||||||
{
|
}
|
||||||
rigidBody.AddForce(transform.forward * force);
|
|
||||||
}
|
|
||||||
|
|
||||||
// destroy for everyone on the server
|
// set velocity for server and client. this way we don't have to sync the
|
||||||
[Server]
|
// position, because both the server and the client simulate it.
|
||||||
void DestroySelf()
|
void Start()
|
||||||
{
|
{
|
||||||
NetworkServer.Destroy(gameObject);
|
rigidBody.AddForce(transform.forward * force);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ServerCallback because we don't want a warning if OnTriggerEnter is
|
// destroy for everyone on the server
|
||||||
// called on the client
|
[Server]
|
||||||
[ServerCallback]
|
void DestroySelf()
|
||||||
void OnTriggerEnter(Collider co)
|
{
|
||||||
{
|
NetworkServer.Destroy(gameObject);
|
||||||
NetworkServer.Destroy(gameObject);
|
}
|
||||||
|
|
||||||
|
// ServerCallback because we don't want a warning if OnTriggerEnter is
|
||||||
|
// called on the client
|
||||||
|
[ServerCallback]
|
||||||
|
void OnTriggerEnter(Collider co)
|
||||||
|
{
|
||||||
|
NetworkServer.Destroy(gameObject);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using UnityEngine.AI;
|
using UnityEngine.AI;
|
||||||
|
|
||||||
namespace Mirror.Examples.Movement
|
namespace Mirror.Examples.Tanks
|
||||||
{
|
{
|
||||||
public class Tank : NetworkBehaviour
|
public class Tank : NetworkBehaviour
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user