今月のコード
Unity/C#研究中です。
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class BallGame : MonoBehaviour {
GameObject textObject;
Text scoreText;
void Start () {
float INIT_SPEED = 15f;
float INIT_DEGREE = 60f;
Rigidbody rb = gameObject.GetComponent();
Vector3 vel = Vector3.zero;
vel.y = INIT_SPEED;
vel.x = INIT_SPEED*Mathf.Cos(INIT_DEGREE*Mathf.PI/180f);
vel.y = INIT_SPEED*Mathf.Sin(INIT_DEGREE*Mathf.PI/180f);
rb.velocity = vel;
textObject = GameObject.Find("Text");
scoreText = textObject.GetComponent();
}
void FixedUpdate(){
scoreText.text = "X:" + gameObject.transform.position.x.ToString();
}
void Update () {
}
}