コード例 #1
0
 // Start is called before the first frame update
 void Start()
 {
     Instance        = this;
     cam             = Camera.main;
     item.useGravity = false;
     item            = GetComponent <Rigidbody>();
     launchEquation  = GetComponentInParent <Player>().GetComponentInChildren <LaunchToDestination>();
 }
コード例 #2
0
    private void Update()
    {
        if (isAlive)
        {
            if (Input.GetMouseButtonDown(0) && currentItems[currentSlotNumber] > 0)
            {
                if (currentItems[currentSlotNumber] >= itemLauncherPrefabList[currentSlotNumber].requiredAmount)
                {
                    currentItems[currentSlotNumber] -= itemLauncherPrefabList[currentSlotNumber].requiredAmount;
                    item = Instantiate(itemLauncherPrefabList[currentSlotNumber], launchPosition.position, transform.rotation);

                    item.transform.parent = launchPosition;
                }


                //ballProjectile.launcher = launchPosition;
            }

            if (Input.GetKeyDown(KeyCode.E))
            {
                PickUpItem();
            }

            velocity = new Vector3(Input.GetAxisRaw("Horizontal"), 0, Input.GetAxisRaw("Vertical")).normalized *movementSpeed;


            Ray        ray        = cam.ScreenPointToRay(Input.mousePosition);
            LayerMask  groundMask = LayerMask.GetMask("MousePosition");
            RaycastHit hitInfo;

            if (Physics.Raycast(ray, out hitInfo, 100, groundMask))
            {
                Vector3 groundPosition = new Vector3(hitInfo.point.x, 0, hitInfo.point.z);

                if (Vector3.Magnitude(groundPosition - transform.position) > minRotationDistance)
                {
                    transform.LookAt(groundPosition + Vector3.up * transform.position.y);
                }
            }
        }
    }