mirror of
https://github.com/GTA-ASM/SanAndreasUnity
synced 2025-02-17 05:18:27 +00:00
implement acceleration
This commit is contained in:
parent
7cba029b92
commit
4eed0a4bbe
1 changed files with 12 additions and 0 deletions
|
@ -16,6 +16,8 @@ namespace SanAndreasUnity.Behaviours
|
|||
public float explosionDamageRadius = 5;
|
||||
public float particleSystemMultiplier = 1;
|
||||
public float speed = 10;
|
||||
public float acceleration = 4;
|
||||
public float maxSpeed = 50;
|
||||
public float rotationSpeed = 180;
|
||||
public float lifeTime = 30;
|
||||
[SerializeField] private Transform m_modelAttachTransform = null;
|
||||
|
@ -79,8 +81,18 @@ namespace SanAndreasUnity.Behaviours
|
|||
|
||||
private void Update()
|
||||
{
|
||||
// rotate model
|
||||
float delta = this.rotationSpeed * Time.deltaTime * Random.Range (0.75f, 1.25f);
|
||||
m_modelAttachTransform.rotation *= Quaternion.AngleAxis (delta, Vector3.forward);
|
||||
|
||||
// accelerate projectile
|
||||
Vector3 currentVectorSpeed = this.RigidBody.velocity;
|
||||
float currentSpeed = currentVectorSpeed.magnitude;
|
||||
if (currentSpeed < this.maxSpeed)
|
||||
{
|
||||
float newSpeed = currentSpeed + this.acceleration * Time.deltaTime;
|
||||
this.RigidBody.velocity = currentVectorSpeed.normalized * newSpeed;
|
||||
}
|
||||
}
|
||||
|
||||
private void OnCollisionEnter(Collision other)
|
||||
|
|
Loading…
Add table
Reference in a new issue