728x90
728x170
Movement
using UnityEngine;
using System.Collections;
public class Movement : MonoBehaviour {
// Use this for initialization
void Start () {
rigidbody.AddForce(Vector3.up * 10.0f,ForceMode.Impulse);
}
}
PickSelect
using UnityEngine;
using System.Collections;
public class PickSelect : MonoBehaviour {
// Update is called once per frame
void Update () {
if(Input.GetMouseButton(0))
{
Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
RaycastHit hit = new RaycastHit();
if(Physics.Raycast(ray, out hit,Mathf.Infinity))
{
hit.collider.gameObject.GetComponent<HingeJoint>().useMotor = true;
hit.collider.gameObject.GetComponent<HingeJoint>().anchor = new Vector3(-0.5f,0.0f,0.0f);
hit.collider.gameObject.GetComponent<HingeJoint>().axis = new Vector3(0.0f,0.0f,1.0f);
hit.collider.gameObject.rigidbody.constraints = RigidbodyConstraints.None;
}
}
}
}
Rotate
using UnityEngine;
using System.Collections;
public class Rotate : MonoBehaviour {
public float Speed = 100.0f;
// Update is called once per frame
void Update () {
rigidbody.AddTorque(Vector3.forward * Speed,ForceMode.Impulse);
}
}
728x90
그리드형
'IT > 유니티' 카테고리의 다른 글
유니티 게임 프로그래밍 18장 예제 구현 (0) | 2021.05.30 |
---|---|
유니티 게임 프로그래밍 16장 예제 구현 (0) | 2021.05.30 |
유니티 게임 프로그래밍 10장 예제 구현 (0) | 2021.05.30 |
유니티 게임 프로그래밍 9장 예제 구현 (0) | 2021.05.30 |
유니티 게임 프로그래밍 8장 예제 구현 (0) | 2021.05.30 |
댓글