study/first_study/Assets/Player/Excution/SimpleThrowNiddle.cs
jh04010421 339a595ac1 윤지호 | 유니티 연습
20226.01.27 수정 (태그 구현중, 오브젝트별 컴포넌트 배치필요)
2026-01-27 20:58:00 +09:00

40 lines
1.0 KiB
C#

using UnityEngine;
using UnityEngine.InputSystem;
public class SimpleThrowNiddle : MonoBehaviour
{
[SerializeField] private GameObject niddle;
private Vector2 axis;
// Start is called once before the first execution of Update after the MonoBehaviour is created
void Start()
{
}
// Update is called once per frame
void Update()
{
if (Keyboard.current.xKey.wasPressedThisFrame)
{
GameObject niddle_clone = Instantiate(niddle);
niddle_clone.transform.position = gameObject.transform.position;
SimpleNiddleMove niddlemove = niddle_clone.GetComponent<SimpleNiddleMove>();
if(axis.y == 0)
{
niddlemove.direction = -gameObject.transform.localScale.x;
}
else
{
niddlemove.direction = axis.x;
}
niddlemove.isup = axis.y;
}
}
void OnMove(InputValue value)
{
axis = value.Get<Vector2>();
}
}