-
Notifications
You must be signed in to change notification settings - Fork 0
/
arvr8.txt
32 lines (28 loc) · 1004 Bytes
/
arvr8.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class cap : MonoBehaviour
{
// Start is called before the first frame update
public float _rotationSpeed = 20f;
private Vector3 _horizontalMovement;
void Start()
{
}
// Update is called once per frame
void Update()
{
_horizontalMovement = new Vector3(0f, 0f, -Input.GetAxis("Horizontal"));
transform.Rotate(_horizontalMovement * _rotationSpeed * Time.deltaTime);
if (Input.GetKey(KeyCode.Space))
{
Debug.DrawRay(transform.position, transform.TransformDirection(Vector2.up) * 100f, Color.red);
RaycastHit2D hit = Physics2D.Raycast(transform.position, transform.TransformDirection(Vector2.up), 100f);
if (hit)
{
Debug.Log(hit.collider.name);
hit.transform.GetComponent<SpriteRenderer>().color = Color.red;
}
}
}
}