Pun-01/Assets/Photon/PhotonUnityNetworking/Demos/DemoAsteroids/Scripts/Game/Bullet.cs

31 lines
789 B
C#
Raw Normal View History

2022-07-08 09:14:55 +08:00
using Photon.Realtime;
using UnityEngine;
namespace Photon.Pun.Demo.Asteroids
{
public class Bullet : MonoBehaviour
{
public Player Owner { get; private set; }
public void Start()
{
Destroy(gameObject, 3.0f);
}
public void OnCollisionEnter(Collision collision)
{
Destroy(gameObject);
}
public void InitializeBullet(Player owner, Vector3 originalDirection, float lag)
{
Owner = owner;
transform.forward = originalDirection;
Rigidbody rigidbody = GetComponent<Rigidbody>();
rigidbody.velocity = originalDirection * 200.0f;
rigidbody.position += rigidbody.velocity * lag;
}
}
}