You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
30 lines
669 B
30 lines
669 B
using UnityEngine;
|
|
|
|
namespace Mirror.Examples.RigidbodyPhysics
|
|
{
|
|
[RequireComponent(typeof(Rigidbody))]
|
|
public class AddForce : NetworkBehaviour
|
|
{
|
|
public Rigidbody rigidbody3d;
|
|
public float force = 500f;
|
|
|
|
void OnValidate()
|
|
{
|
|
rigidbody3d = GetComponent<Rigidbody>();
|
|
rigidbody3d.isKinematic = true;
|
|
}
|
|
|
|
public override void OnStartServer()
|
|
{
|
|
rigidbody3d.isKinematic = false;
|
|
}
|
|
|
|
[ServerCallback]
|
|
void Update()
|
|
{
|
|
if (Input.GetKeyDown(KeyCode.Space))
|
|
rigidbody3d.AddForce(Vector3.up * force);
|
|
}
|
|
}
|
|
}
|