(I use it for the character to change direction and rotate 180º on the “x” axis every time I tap or click) now, what I want is to know where (under what line of code should I code and what should I code so that at the same time I click on it activates a particle system that I have already configured
(I am very new in programming and in unity “please help”), this is the whole code:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class movement: MonoBehaviour {
[SerializeField]
private float xLimit = 7.7f;
[SerializeField]
private float moveSpeed;
[SerializeField]
private Animator anim;
private bool movingRight = true;
private int direction = 1;
private bool startMoving = false;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
if (Input.GetMouseButtonDown (0) && startMoving == false) {
startMoving = true;
}
if (Input.GetMouseButtonDown (0)) {
movingRight =! movingRight;
direction = -direction;
transform.localScale = new Vector3 (direction, 1, 1);
}
if (startMoving == false)
return;
changeDirection ();
transform.position + = Vector3.right * moveSpeed * Time.deltaTime * direction;
transform.position = new Vector3 (Mathf.Clamp (transform.position.x, -7.8f, xLimit), transform.position.y, transform.position.z);
anim.SetBool ("Start", startMoving);
}
void changeDirection () {
if (movingRight && transform.position.x> = xLimit) {
movingRight = false;
direction = -1;
transform.localScale = new Vector3 (direction, 1, 1);
}
if (! movingRight && transform.position.x <= -7.8f) {
movingRight = true;
direction = 1;
transform.localScale = new Vector3 (direction, 1, 1);
}
}
}