У меня есть 5 префабов в качестве вариантов игроков, в меню игры есть кнопка «Изменить», на которую пользователь может нажать и изменить персонажа.
Как мне сделать этот выбор в «Меню» применяется при запуске game2d?
Префабы: Bee, Bee1, Bee2, Bee3 и Bee4.
Скрипт Bee (игрока):
using UnityEngine;
using System.Collections;
using UnityEngine.UI;
using UnityStandardAssets.CrossPlatformInput;
public class Bee : MonoBehaviour {
public float moveSpeed;
public Transform bee;
private Animator animator;
public bool isGrounded = true;
public float force;
public float jumpTime = 0.1f;
public float jumpDelay = 0.1f;
public bool jumped = false;
public Transform ground;
void Start ()
{
animator = bee.GetComponent ();
}
void Update ()
{
Move ();
}
void Move ()
{
isGrounded = Physics2D.Linecast (this.transform.position, ground.position, 1 0) {
transform.Translate (Vector2.right * moveSpeed * Time.deltaTime);
transform.eulerAngles = new Vector2 (0, 0);
}
if (CrossPlatformInputManager.GetAxisRaw ("Horizontal") < 0) {
transform.Translate (Vector2.right * moveSpeed * Time.deltaTime);
transform.eulerAngles = new Vector2 (0, 180);
}
if (CrossPlatformInputManager.GetButtonDown ("Vertical") && isGrounded && !jumped) {
// rigidbody2D.AddForce (transform.up * force);
GetComponent ().AddForce (transform.up * force);
jumpTime = jumpDelay;
animator.SetTrigger ("jumpB");
jumped = true;
}
jumpTime -= Time.deltaTime;
if (jumpTime
Подробнее здесь: https://stackoverflow.com/questions/370 ... ab-unity3d
Создание экземпляра префаба Unity 3D ⇐ C#
-
- Похожие темы
- Ответы
- Просмотры
- Последнее сообщение
-
-
Неизвестное пространство включается в имя префаба при создании экземпляра.
Anonymous » » в форуме C# - 0 Ответы
- 11 Просмотры
-
Последнее сообщение Anonymous
-