The portal to the next level appear after you will collected all coins.
Hello everyone. I'm making a balancing ball game. Now, i would like to make a portal to the next level, but player have to collect all "5" coins. After he collected 5 coins, the portal appear. Can you help me how script should be like? I have no idea... :(
Scripts:
Player Controller:
using UnityEngine; using System.Collections;
public class BallMotor : MonoBehaviour { public float moveSpeed = 5.0f; public float drag = 0.5f; public float terminalRotationSpeed = 25.0f; public Vector3 MoveVector { set; get; } public VirtualJoystick joystick;
private Rigidbody thisRigidbody;
private void Start()
{
thisRigidbody = gameObject.AddComponent<Rigidbody>();
thisRigidbody.maxAngularVelocity = terminalRotationSpeed;
thisRigidbody.drag = drag;
}
private void Update()
{
MoveVector = PoolInput();
Move();
}
private void Move()
{
thisRigidbody.AddForce((MoveVector * moveSpeed));
}
private Vector3 PoolInput()
{
Vector3 dir = Vector3.zero;
// dir.x = PoolInput.GetAxis("Horizontal");
// dir.z = PoolInput.GetAxis("Vertical");
dir.x = joystick.Horizontal();
dir.z = joystick.Vertical();
if (dir.magnitude > 1)
dir.Normalize();
return dir;
}
}
CoinPickUp:
pragma strict
var coinEffect : Transform; var coinValue = 100;
function OnTriggerEnter (info : Collider) { if (info.tag == "Player") {
GameMaster.currentScore += coinValue;
var effect = Instantiate(coinEffect, transform.position, transform.rotation);
Destroy(effect.gameObject, 3);
Destroy(gameObject);
}
}
EndPoint:
pragma strict
var gameMaster : GameMaster;
function OnTriggerEnter (colInfo : Collider) {
if (colInfo.tag == "Player")
{
gameMaster.LoadNextLevel();
}
}