我现在正在为退出而苦苦挣扎。我有一个游戏对象,它是一个球体,它是我在 3d 地形上的播放器。我有一个相机,它总是与玩家保持固定距离,跟随它跟随下面的脚本:
public GameObject player;
private Vector3 offset;
// Use this for initialization
void Start () {
offset = transform.position - player.transform.position;
}
void LateUpdate () {
transform.position = player.transform.position + offset;
}
Run Code Online (Sandbox Code Playgroud)
到现在为止还挺好。然而我真正想要的是相机随着玩家旋转,所以它总是看球体移动的方向,但总是在玩家后面保持相同的固定距离,这样玩家在相机视图中总是可见的.
有很多脚本可用,但到目前为止我所看到的曾经的问题是摄像机确实随着玩家旋转,但是因为玩家实际上是一个滚动球体,所以摄像机视图也在滚动和转动。
到目前为止我找到的最好的脚本如下,但是这个脚本和其他脚本有同样的问题,相机随着播放器滚动。
public Transform target;
public float distance = 3.0f;
public float height = 3.0f;
public float damping = 5.0f;
public bool smoothRotation = true;
public bool followBehind = true;
public float rotationDamping = 10.0f;
void Update () {
Vector3 wantedPosition;
if(followBehind)
wantedPosition = target.TransformPoint(0, …Run Code Online (Sandbox Code Playgroud) 我有一个结构集.
struct Neighbour
{
int ID;
int Left;
int Right;
}
set<NodeNeighbour>NextDoor;
Run Code Online (Sandbox Code Playgroud)
如何在此集中找到ID =='要搜索的数字'?
使用straigth前向集,可以使用set.find()简单地找到一个项目.搜索一组结构有什么类似的东西吗?
Thx提前
我确实在下面定义了struct
struct WayStruct{
double ID;
string Neighbours;
};
Run Code Online (Sandbox Code Playgroud)
并在地图下方
map <double,WayStruct> WayMap;
Run Code Online (Sandbox Code Playgroud)
要使用添加新元素到此地图
WaysFind.ID=999;
WaysFind.Neighbours="test";
WayMap.insert(1234,WaysFind);
Run Code Online (Sandbox Code Playgroud)
但是我无法编译.Dev-C++以错误结束
[Error] no matching function for call to 'std::map<double, WayStruct>::insert(double, WayStruct&)'
Run Code Online (Sandbox Code Playgroud)
谁能告诉我这里做错了什么?
当我使用make_pair Dev-C++返回时
In instantiation of 'std::pair<_T1, _T2>::pair(const std::pair<_U1, _U2>&) [with _U1 = double; _U2 = int; _T1 = const char; _T2 = WayStruct]':
required from here
111 39 c:\program files (x86)\dev-cpp\mingw64\lib\gcc\x86_64-w64-mingw32\4.7.1\include\c++\bits\stl_pair.h [Error] no matching function for call to 'WayStruct::WayStruct(const int&)'
Run Code Online (Sandbox Code Playgroud)
在文件stl_pair.h中