Hello
I have rolling stones on my scene, the stones are throwing from the cannon in small part of time.
I want to stop the stones and throwing it for a while when Player drag the the lever on,
how could I do it?
I tried the function: Time.timeScale = 0; but it stops all the game,
I want only stop movement of the stones and throwing from the cannon,
how could I do that in C#?
I know that i have to use “Is Kinematic” on each stone Rigidbody instantiate, how can i do?
It’s cannon script:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class stonelauncher : MonoBehaviour {
private float number = 10;
public float time = 2.7f;
public Rigidbody stonePrefab;
public Transform stonePosition;
void Start () {
StartCoroutine (Spawn_stone());
}
IEnumerator Spawn_stone() {
for(var i = 0; i < number ; i = i + 0) {
Rigidbody stoneInstance;
stoneInstance = Instantiate (stonePrefab, stonePosition.position, stonePosition.rotation) as Rigidbody;
stoneInstance.AddForce (stonePosition.right * 7, ForceMode.Impulse);
yield return new WaitForSeconds (time);
}
}
}
Thanks for all advices and sorry for my poor english.