本文整理汇总了C#中GameObject.SetPosition方法的典型用法代码示例。如果您正苦于以下问题:C# GameObject.SetPosition方法的具体用法?C# GameObject.SetPosition怎么用?C# GameObject.SetPosition使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GameObject
的用法示例。
在下文中一共展示了GameObject.SetPosition方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: makeGrid
private void makeGrid(Vector3 begin, Vector3 end)
{
LineRenderer line = new GameObject().AddComponent<LineRenderer>();
line.transform.parent = this.transform.parent;
line.SetWidth(0.01F, 0.01F);
line.SetColors(lightBlue, lightBlue);
line.SetPosition(0, begin);
line.SetPosition(1, end);
line.SetVertexCount(2);
line.material = new Material(Shader.Find("Particles/Additive"));
}
示例2: MakeLine
private void MakeLine(Networkable a, Networkable b)
{
var dir = -Camera.main.transform.forward;
var line = new GameObject("Line").AddComponent<LineRenderer>();
line.transform.parent = transform;
line.SetWidth(0.4f, 0.4f);
line.SetPosition(0, a.transform.position + dir * 7);
line.SetPosition(1, b.transform.position + dir * 7);
line.sharedMaterial = NodeMaterial;
}
示例3: MoveUp
internal static void MoveUp(GameObject sim, float meters)
{
sim.SetPosition(
new Vector3(
sim.Position.x,
sim.Position.y + meters,
sim.Position.z));
}
示例4: MoveForward
internal static void MoveForward(GameObject sim, float meters)
{
sim.SetPosition(
new Vector3(
sim.Position.x + (sim.ForwardVector.x * meters),
sim.Position.y,
sim.Position.z + (sim.ForwardVector.z * meters)));
}
示例5: DrawOnMove
void DrawOnMove()
{
//Se os valores X ou Y da variavel MouseLastPosition(Posiçao antiga do mouse) forem diferentes dos valores X ou Y da variavel MouseActualPosition(Posiçao atual do mouse), entao o mouse se moveu
if(MouseLastPosition.x != MouseActualPosition.x || MouseLastPosition.y != MouseActualPosition.y)
{
LineRenderer Line = new GameObject("Line").AddComponent<LineRenderer>();
Line.transform.parent = GameObject.Find("LineMother").transform;
Line.material = LineColor;
Line.SetVertexCount(2);
Line.SetWidth(0.1f,0.1f);
Line.SetPosition(0,Camera.main.ScreenToWorldPoint(new Vector3(MouseLastPosition.x, MouseLastPosition.y, ZPosition)));
Line.SetPosition(1,Camera.main.ScreenToWorldPoint(new Vector3(MouseActualPosition.x, MouseActualPosition.y, ZPosition)));
//Igualando a posiçao antiga do mouse com a atual, para caso ele se mova de novo, a comparaçao seja correta
MouseLastPosition = Input.mousePosition;
}
}
示例6: buildLine
public static void buildLine(Vector3 start, Vector3 end){
LineRenderer line = new GameObject ("Line").AddComponent<LineRenderer> ();
//apparently I should use this as a default material, but it didn't work so I used some arbitrary material
//line.material = new Material(Shader.Find("Particles/Additive"));
line.material = material;
line.gameObject.layer = LayerMask.NameToLayer ("Minimap");
line.material.SetColor ("colour", Color.black);
line.castShadows = false;
line.receiveShadows = false;
line.transform.parent = GameObject.Find("lines").transform;
line.SetWidth(1.0f, 1.0f);
line.SetVertexCount(2);
line.SetPosition(0, start);
line.SetPosition (1, end);
string positions = start.x.ToString () + "," + start.y.ToString () + "," + start.z.ToString () + "," + end.x.ToString () + "," + end.y.ToString () + "," + end.z.ToString ();
if (Network.isServer) {
ClientNetwork client = (ClientNetwork) GameObject.FindObjectOfType(typeof(ClientNetwork));
client.startClientLines (positions);
}
}
示例7: MakeMeLaser
public void MakeMeLaser(Color color)
{
/*
foreach(GameObject go in GameObject.FindObjectsOfType(typeof(GameObject)))
{
if(go.name == "lineUP")
{
GameObject.Destroy (go);
}
}
// Set LineRenderer InitializationGameObject yourName = new GameObject();
LineRenderer lineRenderer = new GameObject("lineUP").AddComponent<LineRenderer>();
lineRenderer.sharedMaterial = new Material(Shader.Find("Particles/Additive"));
lineRenderer.SetColors(Color.red, Color.red);
lineRenderer.SetWidth(1f, 1f);
lineRenderer.SetVertexCount(2);
// We need no Shadows
lineRenderer.castShadows = false;
lineRenderer.receiveShadows = false;
Debug.Log ("Raw posX: " + posX + "Raw posX: " + posY);
float worldX = posX * 4;
float worldZ = posY * 4;
Vector3 pos = new Vector3(worldX + 2, 0, worldZ + 2);
lineRenderer.SetPosition(0, pos);
pos = new Vector3(worldX + 2, 800, worldZ + 2);
lineRenderer.SetPosition(1, pos);
*/
// Make
//GameController.instance.treeGroupController.AddTreeGroup(posX, posY);
RaycastHit hit;
// Set LineRenderer InitializationGameObject yourName = new GameObject();
LineRenderer lineRenderer = new GameObject("lineUP").AddComponent<LineRenderer>();
lineRenderer.sharedMaterial = new Material(Shader.Find("Particles/Additive"));
lineRenderer.SetColors(color, color);
lineRenderer.SetWidth(0.2f, 0.2f);
lineRenderer.SetVertexCount(5);
// We need no Shadows
lineRenderer.castShadows = false;
lineRenderer.receiveShadows = false;
float worldX = posX * 4;
float worldZ = posY * 4;
Vector3 pos;
Ray ray = new Ray(new Vector3(worldX, 10, worldZ), Vector3.up);
if (Physics.Raycast (ray, out hit))
{
pos = new Vector3(worldX, hit.point.y + 1, worldZ);
lineRenderer.SetPosition(0, pos);
}
ray = new Ray(new Vector3(worldX + 4, 10, worldZ), Vector3.up);
if (Physics.Raycast (ray, out hit))
{
pos = new Vector3(worldX + 4, hit.point.y + 1, worldZ);
lineRenderer.SetPosition(1, pos);
}
ray = new Ray(new Vector3(worldX + 4, 10, worldZ + 4), Vector3.up);
if (Physics.Raycast (ray, out hit))
{
pos = new Vector3(worldX + 4, hit.point.y + 1, worldZ + 4);
lineRenderer.SetPosition(2, pos);
}
ray = new Ray(new Vector3(worldX, 10, worldZ + 4), Vector3.up);
if (Physics.Raycast (ray, out hit))
{
pos = new Vector3(worldX, hit.point.y + 1, worldZ + 4);
lineRenderer.SetPosition(3, pos);
}
ray = new Ray(new Vector3(worldX, 10, worldZ), Vector3.up);
if (Physics.Raycast (ray, out hit))
{
pos = new Vector3(worldX, hit.point.y + 1, worldZ);
lineRenderer.SetPosition(4, pos);
}
lineRenderer.gameObject.AddComponent<SelectionLine>();
}
示例8: ParentToSlot
public static void ParentToSlot(GameObject obj, Slot slot, GameObject parent)
{
if (obj != null && parent != null)
{
obj.SetPosition(parent.GetPositionOfSlot(slot));
obj.SetForward(parent.GetForwardOfSlot(slot));
obj.ParentToSlot(parent, slot);
}
}
示例9: drawLine
protected void drawLine(Vector3 start, Vector3 end, Color color)
{
LineRenderer line = new GameObject("Line ").AddComponent<LineRenderer>();
line.SetWidth(0.025F, 0.025F);
line.SetColors(color, color);
line.SetVertexCount(2);
line.SetPosition(0, start);
line.SetPosition(1, end);
line.material.shader = (Shader.Find("Unlit/Color"));
line.material.color = color;
lines.Add(line.gameObject);
}
示例10: RemoveMoveInteractions
public static void RemoveMoveInteractions(GameObject gameObject, bool resetLocation)
{
if (MovedObjects.ContainsKey(gameObject))
{
if (resetLocation)
{
LocationVectors vectors;
if (MovedObjects.TryGetValue(gameObject, out vectors))
{
gameObject.SetForward(vectors.ForwardVector);
gameObject.SetPosition(vectors.Position);
}
}
MovedObjects.Remove(gameObject);
}
gameObject.RemoveInteractionByType(StopMovingMe.Singleton);
gameObject.RemoveInteractionByType(TurnLeft.Singleton);
gameObject.RemoveInteractionByType(TurnAtAngle.Singleton);
gameObject.RemoveInteractionByType(TurnRight.Singleton);
gameObject.RemoveInteractionByType(TurnAround.Singleton);
gameObject.RemoveInteractionByType(TiltFaceUp.Singleton);
gameObject.RemoveInteractionByType(TiltBack.Singleton);
gameObject.RemoveInteractionByType(TiltForward.Singleton);
gameObject.RemoveInteractionByType(TiltFaceDown.Singleton);
gameObject.RemoveInteractionByType(TiltUserDefined.Singleton);
gameObject.RemoveInteractionByType(MoveUp.Singleton);
gameObject.RemoveInteractionByType(MoveUpUserDefined.Singleton);
gameObject.RemoveInteractionByType(MoveDown.Singleton);
gameObject.RemoveInteractionByType(MoveDownUserDefined.Singleton);
gameObject.RemoveInteractionByType(MoveBack.Singleton);
gameObject.RemoveInteractionByType(MoveBackUserDefined.Singleton);
gameObject.RemoveInteractionByType(MoveForward.Singleton);
gameObject.RemoveInteractionByType(MoveForwardUserDefined.Singleton);
gameObject.RemoveInteractionByType(MoveRight.Singleton);
gameObject.RemoveInteractionByType(MoveRightUserDefined.Singleton);
gameObject.RemoveInteractionByType(MoveLeft.Singleton);
gameObject.RemoveInteractionByType(MoveLeftUserDefined.Singleton);
}
示例11: makeLineGraph
private void makeLineGraph(Vector3 begin, Vector3 end)
{
//makePoint(begin);
// makePoint(end);
LineRenderer line = new GameObject().AddComponent<LineRenderer>();
line.transform.parent = this.transform.parent;
line.SetWidth(0.05F, 0.05F);
line.SetColors(Color.green, Color.green);
line.SetPosition(0, begin);
line.SetPosition(1, end);
line.SetVertexCount(2);
line.material = new Material(Shader.Find("Particles/Additive"));
}