31 lines
802 B
C#
31 lines
802 B
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
public class BlowZone : MonoBehaviour
|
|
{
|
|
private Rigidbody playerRb;
|
|
private ParticleSystem particles;
|
|
[SerializeField]
|
|
private Vector3 dir;
|
|
[SerializeField]
|
|
private float force;
|
|
// Start is called before the first frame update
|
|
void Start()
|
|
{
|
|
particles = GetComponent<ParticleSystem>();
|
|
var mainPart = particles.main;
|
|
mainPart.startSpeedMultiplier = force/3;
|
|
}
|
|
|
|
private void OnTriggerStay(Collider other) {
|
|
if(other.tag.Equals("Player")){
|
|
if(playerRb == null){
|
|
playerRb = other.gameObject.GetComponent<Rigidbody>();
|
|
}
|
|
playerRb.AddForce(transform.forward * force);
|
|
|
|
}
|
|
}
|
|
}
|