iam trying to make a 2d drop and catch game and when i apply a script the catching object disappears and it doesn’t let me control the catching object
if any one has any tips or ideas on how to fix this please let me know
the script iam using is this one (i did not write the script my self i found it online) and the type of game iam trying to make is there is one object on a base that moves side to side catching falling objects and exploding once it makes contact with the base object
using UnityEngine;
using System.Collections;
public class twoDeePlatformerScript : MonoBehaviour {
public float speed = 6.0F;
public float jumpSpeed = 8.0F;
public float gravity = 20.0F;
private bool land = true;
public float PressStartTime = 4.0f;
public float ZPosition = 23F;
public bool isStillPressed = false;
public float JumpModifyer;
public GameObject ParticleEffect; //Particle effect to instantiate
private GameObject footFall;//cloned object's name
public Vector2 moveDirection = Vector2.zero;
private Vector3 myMovement;
void Update() {
CharacterController controller = GetComponent<CharacterController>();
//script to make a variable "Mario Jump"//
if (Input.GetKeyDown(KeyCode.Space)){
isStillPressed = true;
}
else if (Input.GetKeyUp (KeyCode.Space)){
isStillPressed = false;
}
if (isStillPressed){
PressStartTime += Time.deltaTime* 20;
JumpModifyer = PressStartTime + jumpSpeed;
}
if (controller.isGrounded) {
if (land == true){
footFall = Instantiate(ParticleEffect, new Vector3(transform.position.x,transform.position.y - 1,transform.position.z), Quaternion.identity) as GameObject;//instantiate particle effect
land = false;
}
moveDirection = new Vector2(Input.GetAxis("Horizontal"), 0);
moveDirection = transform.TransformDirection(moveDirection);
moveDirection *= speed;
PressStartTime = 1;
if (Input.GetButton("Jump")){
if(JumpModifyer > 15){JumpModifyer = 15;}
moveDirection.y = JumpModifyer;
audio.Play();
}
}
//script to give small amout of "after touch" to in air jumps//
if (controller.isGrounded != true){
moveDirection.x = Input.GetAxis("Horizontal")* speed;
land = true;
}
moveDirection.y -= gravity * Time.deltaTime;
controller.Move(moveDirection * Time.deltaTime);
transform.position = new Vector3(transform.position.x,transform.position.y, ZPosition);
}
public void OnTriggerEnter(Collider thing){
if(thing.gameObject.tag == "NOTHING"){
print("I killed ya Daddy-O");
Destroy(gameObject);
}
}
}