Exemple #1
0
    void ShootSquirt()
    {
        //Rigidbody2D SquirtClone;
        GameObject SquirtClone;
        //Rigidbody2D SquirtCloneRb2d;

        //float SquirtCloneForce = 120f;
        float ThiefToGhostLerpDistancePct = 0.2f;

        //get intrapolated distance from thief to player
        Vector3 ThiefToGhostLerp = Vector3.Lerp(transform.position, Player.transform.position, ThiefToGhostLerpDistancePct / ((transform.position - Player.transform.position).magnitude));

        //print("PointToPlayer-> X, Y : " + ThiefToGhostLerp.x + "," + ThiefToGhostLerp.y);
        //print("Squirt Shot!");

        //*calculate squirt rotation to point to ghost
        Quaternion SquirtRotationInDegrees_z = Quaternion.Euler(0f, 0f, GetAngleBetweenVectors(Player.transform.position, transform.position) - 90);

        //*instantiate squirt in position and rotated
        SquirtClone = Instantiate(Squirt, ThiefToGhostLerp, SquirtRotationInDegrees_z) as GameObject;
        //SquirtCloneRb2d = Instantiate(squirt, ThiefToGhostLerp, SquirtRotationInDegrees_z) as Rigidbody2D;

        SquirtMovementHoming SquirtHomingScript = SquirtClone.GetComponent <SquirtMovementHoming>();

        SquirtHomingScript.Target = Player;
    }
Exemple #2
0
    void ShootSquirt()
    {
        //Rigidbody2D SquirtClone;
        GameObject SquirtClone;
        //Rigidbody2D SquirtCloneRb2d;

        float SquirtCloneForce            = 120f;
        float ThiefToGhostLerpDistancePct = 0.2f;

        //get intrapolated distance from thief to player
        Vector3 ThiefToGhostLerp = Vector3.Lerp(transform.position, GhostGameObject.transform.position, ThiefToGhostLerpDistancePct / ((transform.position - GhostGameObject.transform.position).magnitude));

        //print("PointToPlayer-> X, Y : " + ThiefToGhostLerp.x + "," + ThiefToGhostLerp.y);
        print("Squirt Shot!");

        //*calculate squirt rotation to point to ghost
        Quaternion SquirtRotationInDegrees_z = Quaternion.Euler(0f, 0f, GetAngleBetweenVectors(GhostGameObject.transform.position, transform.position) - 90);

        //*instantiate squirt in position and rotated
        SquirtClone = Instantiate(squirt, ThiefToGhostLerp, SquirtRotationInDegrees_z) as GameObject;
        //SquirtCloneRb2d = Instantiate(squirt, ThiefToGhostLerp, SquirtRotationInDegrees_z) as Rigidbody2D;

        Homing SquirtHomingScript = SquirtClone.GetComponent <Homing>();

        SquirtHomingScript.Target = GhostGameObject;

        //*calculate normal vector from squirt to ghost
        Vector3 SquirtCloneToGhostNormal = (GhostGameObject.transform.position - SquirtClone.transform.position).normalized;
        //Vector3 SquirtCloneToGhostNormal = (GhostGameObject.transform.position - SquirtCloneRb2d.transform.position).normalized;

        //*apply force
        //SquirtClone.AddForce(SquirtCloneToGhostNormal * SquirtCloneForce);
        //SquirtCloneRb2d.AddForce(SquirtCloneToGhostNormal * SquirtCloneForce);

        //*pre shooting
        //Rigidbody2D ghostRb2d = GhostGameObject.GetComponent<Rigidbody2D>();
        //Vector2 ghostVelocityV2 = ghostRb2d.velocity.normalized;
        //Vector3 ghostVelocityV3 = new Vector3(ghostVelocityV2.x, ghostVelocityV2.y, 0);
        //SquirtClone.AddForce((SquirtCloneToGhostNormal + ghostVelocityV3) * SquirtCloneForce);
    }