【发布时间】:2018-09-18 13:33:36
【问题描述】:
我目前有一个粒子系统,它应该代表吹叶机。我已经让这个工作在鼠标点击时开启和关闭。
问题是,我希望它像逼真的吹叶机一样“吹”出物体。听说有人喜欢用 AddForceAtPosition 之类的,就是不知道怎么用。
目前,当我的“吹叶机”打开时,我正在启用和禁用一个盒子碰撞器,并让碰撞器接触到的所有东西都被击退,但这证明在游戏中存在各种问题。
这是我正在使用的代码:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class leafblower : MonoBehaviour {
private Rigidbody rb;
protected bool letPlay;
public ParticleSystem blow;
public Collider lcol;
// Use this for initialization
void Start ()
{
rb = GetComponent<Rigidbody>();
blow = GetComponent<ParticleSystem>();
lcol.enabled = !lcol.enabled;
}
void LeafBlower()
{
if (Input.GetKeyDown(KeyCode.Mouse1))
{
var isBlowing = blow.emission;
isBlowing.enabled = true;
lcol.enabled = !lcol.enabled;
}
else if (Input.GetKeyUp(KeyCode.Mouse1))
{
var isBlowing = blow.emission;
isBlowing.enabled = false;
lcol.enabled = !lcol.enabled;
}
}
// Update is called once per frame
void Update()
{
LeafBlower();
}
void FixedUpdate()
{
}
}
我应该添加什么力量,或者我应该在 void OnCollisionEnter() 中添加什么? 非常感谢:)
【问题讨论】:
标签: c# unity3d particle-system