| 1234567891011121314151617181920212223242526272829303132333435363738394041424344 |
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- namespace WildAttack
- {
- public class TestWay : MonoBehaviour
- {
- // Start is called before the first frame update
- void Start()
- {
- }
- public void Init(int i, int k, Vector2 pos, Color color)
- {
- gameObject.name = $"wayPoint{i + 1}_{k + 1}";
- transform.position = new Vector3(pos.x, 30, pos.y);
- transform.localScale = Vector3.one * 2;
- transform.GetComponent<Renderer>().sharedMaterial.color = Color.white;
- transform.GetComponent<Renderer>().material.color = color;
- //gameObject.AddComponent<BoxCollider>();
- //gameObject.AddComponent<Rigidbody>().freezeRotation = true;
- gameObject.layer = LayerMask.NameToLayer("WayPoint");
- Ray ray = new Ray(new Vector3(transform.position.x, 30, transform.position.z), -transform.up);
- RaycastHit hitInfo;
- if (Physics.Raycast(ray, out hitInfo, 100, 1 << LayerMask.NameToLayer("Plane")))
- {
- transform.position = hitInfo.point;
- }
- }
- // Update is called once per frame
- void Update()
- {
- }
- }
- }
|