I have big problem with my particles ![]()
When I move my ship with “wsad”, particle leave trail behind the ship - they should disapear I think but they dont :/. Could anyone can help me with this? Without destroying particles, everything sucks…
Here is my whole script :
I got thir error and meyby this is the problem:
Assets/Moje_Skrypty/LookAtMouse.cs(73,28): warning CS0219: The variable `showEngine’ is assigned but its value is never used
using UnityEngine;
using System.Collections;
public class LookAtMouse : MonoBehaviour
{
// speed is the rate at which the object will rotate
public float speed;
public float shipSpeed;
public GameObject engine;
public GameObject enginePrefab;
public bool engineStarted;
public GameObject showEngine;
void FixedUpdate ()
{
Plane playerPlane = new Plane(Vector3.up, transform.position);
Ray ray = Camera.main.ScreenPointToRay (Input.mousePosition);
float hitdist = 0.0f;
if (playerPlane.Raycast (ray, out hitdist))
{
Vector3 targetPoint = ray.GetPoint(hitdist);
Quaternion targetRotation = Quaternion.LookRotation(targetPoint - transform.position);
transform.rotation = Quaternion.Slerp(transform.rotation, targetRotation, speed * Time.time);
if (Input.GetKey("w") || Input.GetKey("s") || Input.GetKey("a") || Input.GetKey("d"))
//if(silnikiodpalone == false)
{
startEngine();
}
else
{
stopEngine();
}
float movingShipAxisX = Input.GetAxis("Horizontal") * shipSpeed * Time.fixedDeltaTime;
transform.Translate(Vector3.right * movingShipAxisX, Space.World);
float movingShipAxisY = Input.GetAxis("Vertical") * shipSpeed * Time.fixedDeltaTime;
transform.Translate(Vector3.forward * movingShipAxisY, Space.World);
}
}
void startEngine()
{
//if(engineStarted == false)
{
GameObject showEngine = (GameObject)Instantiate(enginePrefab, engine.transform.position, engine.transform.rotation);
}
//engineStarted = true;
}
void stopEngine()
{
Destroy(showEngine);
}
}