Пример #1
0
 // Update is called once per frame
 void Update()
 {
     if (holdingBall)
     {
         Ball.GetComponent <Rigidbody>().useGravity = false;
         Ball.transform.position = PlayerCamera.transform.position + PlayerCamera.transform.forward * BallDistance;
         if (Input.GetKeyDown(KeyCode.Space))
         {
             Ball.ActivateTrail();
             Ball.GetComponent <Rigidbody>().useGravity = true;
             holdingBall = false;
             Ball.GetComponent <Rigidbody>().AddForce(PlayerCamera.transform.forward * ThrowingForce);
         }
     }
 }
Пример #2
0
 // Use this for initialization
 void Start()
 {
     line  = GetComponent <LineRenderer>();
     trail = transform.GetComponentInChildren <Trail>();
     if (random && possibleColor.Length > 0)
     {
         line.colorGradient = possibleColor[Random.Range(0, possibleColor.Length)];
         trail.GetComponent <TrailRenderer>().colorGradient = possibleColor[Random.Range(0, possibleColor.Length)];
     }
     else if (!random && possibleColor.Length > 0)
     {
         line.colorGradient = possibleColor[0];
         trail.GetComponent <TrailRenderer>().colorGradient = possibleColor[0];
     }
     GetOriginalTrianglePath();
     trail.originPath = trianglePath.ToArray();
 }
Пример #3
0
    void Start()
    {
        print("this1");
        projectilePrefab = Resources.Load("Prefabs/Projectile", typeof(Projectile)) as Projectile;
        trailPrefab      = Resources.Load("Prefabs/Trail", typeof(Trail)) as Trail;
        speed            = baseMoveSpeed;

        audio       = GetComponent <AudioSource>();
        projectiles = GameObject.Find("Projectiles");

        playerFlash = Resources.Load <Sprite>("Sprites/PlayerFlash") as Sprite;

        playerSprite = Resources.Load <Sprite>("Sprites/" + characterName) as Sprite;
        GetComponent <SpriteRenderer>().sprite = playerSprite;

        trailSprite = Resources.Load <Sprite>("Sprites/" + characterName + "Trail") as Sprite;
        GameObject player1Full   = GameObject.Find("Player1Full");
        GameObject player2Full   = GameObject.Find("Player2Full");
        Transform  prevTransform = transform;

        for (int i = 0; i < 20; i++)
        {
            Trail newTrail = Instantiate(trailPrefab);
            newTrail.parent = prevTransform;
            prevTransform   = newTrail.transform;

            if (teamNumber == 1)
            {
                newTrail.transform.parent = player1Full.transform;
            }
            else
            {
                newTrail.transform.parent = player2Full.transform;
            }
            newTrail.gameObject.name = teamNumber + "Trail" + i;
            newTrail.teamNumber      = teamNumber;
            newTrail.GetComponent <SpriteRenderer>().sprite = trailSprite;
            newTrail.GetComponent <SpriteRenderer>().color  = new Color(0.5f, 0.5f, 0.5f);
            newTrail.transform.position = new Vector3(transform.position.x + i * 0.35f, transform.position.y, 0.1f);
            //newTrail.player = transform; //Used for alternate movement
            //newTrail.trailNum = i+1;//Used for alternate movement
            //Setlocation!
        }
    }