function Start ()
{
var linkedTerrain:Terrain = gameObject.GetComponent(Terrain);
_terrainGrid[0,0] = Terrain.CreateTerrainGameObject(linkedTerrain.terrainData).GetComponent(Terrain);
_terrainGrid[0,1] = Terrain.CreateTerrainGameObject(linkedTerrain.terrainData).GetComponent(Terrain);
_terrainGrid[0,2] = Terrain.CreateTerrainGameObject(linkedTerrain.terrainData).GetComponent(Terrain);
_terrainGrid[1,0] = Terrain.CreateTerrainGameObject(linkedTerrain.terrainData).GetComponent(Terrain);
_terrainGrid[1,1] = Terrain.CreateTerrainGameObject(linkedTerrain.terrainData).GetComponent(Terrain);
_terrainGrid[1,2] = Terrain.CreateTerrainGameObject(linkedTerrain.terrainData).GetComponent(Terrain);
_terrainGrid[2,0] = Terrain.CreateTerrainGameObject(linkedTerrain.terrainData).GetComponent(Terrain);
_terrainGrid[2,1] = Terrain.CreateTerrainGameObject(linkedTerrain.terrainData).GetComponent(Terrain);
_terrainGrid[2,2] = Terrain.CreateTerrainGameObject(linkedTerrain.terrainData).GetComponent(Terrain);
_terrainGrid[0,0].transform.constantForce = Vector3(0,0,1.0);
}
我在上面的行中出现错误错误:属性UnityEngine.Component.constantForce
是只读的
我想创建Terrain的Materix并在它们上应用ConstantForce以便它们移动。我需要Materix,因为我想重用它们并创建EndLess Envirnoment,因为它们正在移动。 我试着在这一行上得到了错误:
_terrainGrid[X,Y].transform.constantForce = Vector3(0,0,1.0);
ERROR:
Property 'UnityEngine.Component.constantForce' is read only
答案 0 :(得分:0)
尝试使用:
ConstantForce.relativeForce = Vector3(0, 0, 1.0);
constantForce.relativeForce
表示相对于刚体坐标系的力,应用于每个帧。