如何在Unity中双向拍摄?

时间:2017-11-29 14:21:05

标签: c# unity3d unity5

我是Unity的新手,在过去没有使用Unity之前,我从未在C#中编码。我所知道的只是Java和Python。我从高中毕业后就认识Java,现在我是大学二年级学生。我做了我的项目,其中包括我的人性,应该用12只美洲虎射击子弹。我已经从Unity给我们的2d UFO示例中实现了所有这些。我的子弹有一张照片。我真的不知道如何实施子弹。我被要求将子弹射向两个方向。我通过学习如何基本拍摄(一个方向)逐渐开始。我引用了这个链接并将其添加到我的程序中,在添加项目符号代码后它将无法编译。我按照网站的说法在Unity程序中创建了一个球体,并将图像设置为png项目符号。

https://unity3d.com/learn/tutorials/temas/multiplayer-networking/shooting-single-player

现在这是我的代码。我顺便下载了Unity的免费最新版本。顺便说一句,我的游戏是2D游戏。这只是漫画。

using UnityEngine;
using System.Collections;

public class CompleteCameraController : MonoBehaviour {

    public GameObject player;       //Public variable to store a reference to the player game object


    private Vector3 offset;         //Private variable to store the offset distance between the player and camera

    // Use this for initialization
    void Start () 
    {
        //Calculate and store the offset value by getting the distance between the player's position and camera's position.
        offset = transform.position - player.transform.position;
    }

    // LateUpdate is called after Update each frame
    void LateUpdate () 
    {
        // Set the position of the camera's transform to be the same as the player's, but offset by the calculated offset distance.
        transform.position = player.transform.position + offset;
    }
}

其他课程

public IHttpActionResult GetFilter()
        {
            var userFilters = new List<Filter>()
            {
                new Filter { PropertyName = "Username" ,
                    Operation = Op .Equals, Value = "Karan"  },
            };

            var productfilter = new List<Filter>()
            {
                new Filter { PropertyName = "Name" ,
                    Operation = Op .Equals, Value = "Test product"  }
            };

            Func<User, bool> deleg = x => true;
            Func<Product, bool> delegProduct = x => true;

            if (userFilters.Count > 0)
            {
                deleg = ExpressionBuilder.GetExpression<User>(userFilters).Compile();
            }

            if (productfilter.Count > 0)
            {
                delegProduct = ExpressionBuilder.GetExpression<Product>(productfilter).Compile();
            }

            var resultt = _localmarketEntities.Users.Where(deleg)
                .Select(x => new
                {
                    x.Id,
                    x.Username,
                    Product = x.Products.Where(delegProduct).Select(y => new
                    {
                        y.Id,
                        y.Name
                    }).ToList()
                })
                .ToList();

            return Ok(resultt);
        }

0 个答案:

没有答案