The scenario is :
I have an series of object which is moving and I need to shoot the object by clicking on the shooter placed over it.
There is a power up, when clicked on once, should actually slow down the series of object moving underneath the shooter.
I am able to slow it down till the time I click on the power button.
But what i want is to click it once and then the objects moving underneath should move slow for 30 secs and i should be able to shoot the objects from the shooter as it was before but with slow moving objects.
The code i have developed for the power up scenario is:
using UnityEngine;
using System.Collections;
public class target_destroy : MonoBehaviour {
//public static float speed_target;
public GameObject target;
public Transform targetSpawn;
public Sprite apple;
public Sprite appleshit;
public GameObject power1;
private SpriteRenderer myRenderer;
GameObject images1;
Ray ray;
RaycastHit rayHit;
public static float speed_target;
void Start ()
{
//Debug.Log ("convert to shit");
myRenderer = gameObject.GetComponent<SpriteRenderer>();
speed_target = Random.Range (15 , 30);
rigidbody.velocity = transform.right * speed_target;
}
void Update()
{
//if(Input.GetMouseButtonDown (0))
if(Input.GetKeyDown("enter"))
{
ray = Camera.main.ScreenPointToRay(Input.mousePosition);
if(Physics.Raycast(ray, out rayHit))
{
images1 = rayHit.collider.gameObject;
if(images1 != null)
Debug.Log ("Print");
speed_target = Random.Range (10 , 20 );
rigidbody.velocity = transform.right * speed_target;
}
}
}