Пример #1
0
        public override void Run(GameObject obj)
        {
            Vector2        psp = findProjectileSpawnPoint(obj);
            Vector3        mouseScreenPosition = Camera.main.ScreenToWorldPoint(Input.mousePosition);
            float          rotationZ           = Mathf.Atan2(Mathf.Abs(mouseScreenPosition.y - psp.y), Mathf.Abs(mouseScreenPosition.x - psp.x));
            float          dotProd             = CrossProduct(mouseScreenPosition, psp);
            float          rotationY           = dotProd < 0 ? 0 : 180f;
            ProjectileData pd = Instantiate(objectToSpawn, psp, Quaternion.Euler(0, rotationY, rotationZ)).GetComponent <ProjectileData>();

            pd.SetParentId(obj.transform.GetInstanceID());
        }