コード例 #1
0
    void slash()
    { //instantiate means to create. creates the projectile and adds it to the scene as a clone
      //prefab is what is being created, spawnpoint is where, rotation is
        Projectiles temp = Instantiate(projectilePrefabSl, projectileSpawnPointSl.position, projectileSpawnPointSl.rotation);

        temp.GetComponent <Rigidbody2D>().velocity = new Vector2(projectileForceSl, 0); //makes the projectile move when you spawn it

        temp.GetComponent <Rigidbody2D>().velocity = Vector2.right * projectileForceSl; //does the same thing as the one above, just a different way of doing it

        if (isFacingRight)
        {
            temp.speed = projectileForceSl;
        }
        else if (!isFacingRight)
        {
            temp.speed = -projectileForceSl;
        }
    }