麻豆小视频在线观看_中文黄色一级片_久久久成人精品_成片免费观看视频大全_午夜精品久久久久久久99热浪潮_成人一区二区三区四区

首頁 > 學院 > 開發(fā)設(shè)計 > 正文

Unity3D 學習教程 12 C# 發(fā)射炮彈

2019-11-17 02:39:13
字體:
供稿:網(wǎng)友

Unity3D 學習教程 12 C# 發(fā)射炮彈

建立一個炮彈

一個球體

雙擊腳本

進入編輯器

 1 using UnityEngine; 2 using System.Collections; 3  4 public class acc : MonoBehaviour { 5  6     // Use this for initialization 7     public Transform Q; 8     int speed=50; 9     void Start () {10 11     }12     13     // Update is called once per frame14     void Update () {15         float x = Input.GetAxis("Horizontal") * Time.deltaTime * speed;//左右移動16         float z = Input.GetAxis("Vertical") * Time.deltaTime * speed;//    前后移動17         //主攝像機物體    移動18         transform.Translate(x,0,z);19 20         if(Input.GetKeyDown(KeyCode.Mouse0))21         {22             Transform n = (Transform)Instantiate(Q,transform.position,transform.rotation);23             Vector3 f = transform.TransformDirection(Vector3.forward);24             n.rigidbody.AddForce(f*2000);25         }26 27         

public Transform Q;

建立一個炮彈 Q

Transform

Transform 變換

Inherits from Component,IEnumerable

Position, rotation and scale of an object.

物體的位置、旋轉(zhuǎn)和縮放。

Every object in a scene has a Transform. It's used to store and manipulate the position, rotation and scale of the object. Every Transform can have a parent, which allows you to apply position, rotation and scale hierarchically. This is the hierarchy seen in the Hierarchy pane. They also support enumerators so you can loop through children using:

場景中的每一個物體都有一個Transform。用于儲存并操控物體的位置、旋轉(zhuǎn)和縮放。每一個Transform可以有一個父級,允許你分層次應用位置、旋轉(zhuǎn)和縮放。可以在Hierarchy面板查看層次關(guān)系。他們也支持計數(shù)器(enumerator),因此你可以使用循環(huán)遍歷子物體。

using UnityEngine;using System.Collections;public class example : MonoBehaviour {public void Awake() {foreach (Transform child in transform) {child.position += Vector3.up * 10.0F;}}}
// Moves all transform children 10 units upwards!//向上移動所有變換的子物體10個單位for (var child : Transform in transform) {child.position += Vector3.up * 10.0;}

參見:Physics 類.

Variables變量

  • positionThe position of the transform in world space. 在世界空間坐標transform的位置。
  • localPositionPosition of the transform relative to the parent transform. 相對于父級的變換的位置。
  • eulerAnglesThe rotation as Euler angles in degrees. 旋轉(zhuǎn)作為歐拉角度。
  • localEulerAnglesThe rotation as Euler angles in degrees relative to the parent transform's rotation. 旋轉(zhuǎn)作為歐拉角度,相對于父級的變換旋轉(zhuǎn)角度。
  • rightThe red axis of the transform in world space. 在世界空間坐標變換的紅色軸。也就是x軸。
  • upThe green axis of the transform in world space. 在世界空間坐標變換的綠色軸。也就是y軸。
  • forwardThe blue axis of the transform in world space. 在世界空間坐標變換的藍色軸。也就是z軸。
  • rotationThe rotation of the transform in world space stored as a Quaternion. 在世界空間坐標物體變換的旋轉(zhuǎn)角度作為Quaternion儲存。
  • localRotationThe rotation of the transform relative to the parent transform's rotation. 物體變換的旋轉(zhuǎn)角度相對于父級的物體變換的旋轉(zhuǎn)角度。
  • localScaleThe scale of the transform relative to the parent. 相對于父級物體變換的縮放。
  • parentThe parent of the transform. 物體變換的父級。
  • worldToLocalMatrixMatrix that transforms a point from world space into local space (Read Only). 矩陣變換的點從世界坐標轉(zhuǎn)為自身坐標(只讀)。
  • localToWorldMatrixMatrix that transforms a point from local space into world space (Read Only). 矩陣變換的點從自身坐標轉(zhuǎn)為世界坐標(只讀)。
  • rootReturns the topmost transform in the hierarchy. 返回層次最高的變換。
  • childCountThe number of children the Transform has. 變換的子物體數(shù)量。
  • lossyScaleThe global scale of the object (Read Only). 物體的全局縮放(只讀)。

Functions函數(shù)

  • TranslateMoves the transform in the direction and distance of translation. 移動transform在translation的方向和距離。
  • RotateApplies a rotation of eulerAngles.z degrees around the z axis, eulerAngles.x degrees around the x axis, and eulerAngles.y degrees around the y axis (in that order). 應用一個歐拉角的旋轉(zhuǎn)角度,eulerAngles.z度圍繞z軸,eulerAngles.x度圍繞x軸,eulerAngles.y度圍繞y軸(這樣的順序)。
  • RotateAroundRotates the transform about axis passing through point in world coordinates by angle degrees. 按照angle度通過在世界坐標的point軸旋轉(zhuǎn)物體。
  • LookAtRotates the transform so the forward vector points at /target/'s current position. 旋轉(zhuǎn)物體,這樣向前向量指向target的當前位置。
  • TransformDirectionTransforms direction from local space to world space. 從自身坐標到世界坐標變換方向。
  • InverseTransformDirectionTransforms a direction from world space to local space. The opposite of Transform.TransformDirection. 變換方向從世界坐標到自身坐標。和Transform.TransformDirection相反。
  • TransformPointTransforms position from local space to world space. 變換位置從自身坐標到世界坐標。
  • InverseTransformPointTransforms position from world space to local space. The opposite of Transform.TransformPoint. 變換位置從世界坐標到自身坐標。和Transform.TransformPoint相反。
  • DetachChildrenUnparents all children. 所有子物體解除父子關(guān)系。
  • FindFinds a child by name and returns it. 通過名字查找子物體并返回它。
  • IsChildOfIs this transform a child of parent? 這個變換是父級的子物體?

Inherited members繼承成員

Inherited Variables繼承變量

  • transformThe Transform attached to this GameObject (null if there is none attached). Transform附加到GameObject(游戲物體)(如無附加則為空)。
  • rigidbodyThe Rigidbody attached to this GameObject (null if there is none attached). Rigidbody附加到GameObject(游戲物體)(如無附加則為空)。
  • cameraThe Camera attached to this GameObject (null if there is none attached). Camera附加到GameObject(游戲物體)(如無附加則為空)。
  • lightThe Light attached to this GameObject (null if there is none attached). Light附加到GameObject(游戲物體)(如無附加則為空)。
  • animationThe Animation attached to this GameObject (null if there is none attached). Animation附加到GameObject(游戲物體)(如無附加則為空)。
  • constantForceThe ConstantForce attached to this GameObject (null if there is none attached). ConstantForce附加到GameObject(游戲物體)(如無附加則為空)。
  • rendererThe Renderer attached to this GameObject (null if there is none attached). Renderer附加到GameObject(游戲物體)(如無附加則為空)。
  • audioThe AudioSource attached to this GameObject (null if there is none attached). AudioSource附加到GameObject(游戲物體)(如無附加則為空)。
  • guiTextThe GUIText attached to this GameObject (null if there is none attached). GUIText附加到GameObject(游戲物體)(如無附加則為空)。
  • networkViewThe NetworkView attached to this GameObject (Read Only). (null if there is none attached) NetworkView附加到GameObject(游戲物體)(只讀)(如無附加則為空)。
  • guiTextureThe GUITexture attached to this GameObject (Read Only). (null if there is none attached) GUITexture附加到GameObject(游戲物體)(只讀)(如無附加則為空)。
  • colliderThe Collider attached to this GameObject (null if there is none attached). Collider附加到GameObject(游戲物體)(如無附加則為空)。
  • hingeJointThe HingeJoint attached to this GameObject (null if there is none attached). HingeJoint附加到GameObject(游戲物體)(如無附加則為空)。
  • particleEmitterThe ParticleEmitter attached to this GameObject (null if there is none attached). ParticleEmitter附加到GameObject(游戲物體)(如無附加則為空)。
  • gameObjectThe game object this component is attached to. A component is always attached to a game object. 組件附加的游戲物體。一個組件總是被附加到一個游戲物體。
  • tagThe tag of this game object. 游戲物體的標簽。
  • nameThe name of the object. //物體的名字
  • hideFlagsShould the object be hidden, saved with the scene or modifiable by the user? 物體是否被隱藏、保存在場景中或被用戶修改?

Inherited Functions繼承函數(shù)

  • GetComponentReturns the component of Type type if the game object has one attached, null if it doesn't. 如果游戲物體有一個附加,則返回Type類型的組件,如果沒有則為null。
  • GetComponent.<T>
  • GetComponentReturns the component with name type if the game object has one attached, null if it doesn't. 如果游戲物體有一個附加,則返回名字類型組件,如果沒有則為null。
  • GetComponentInChildrenReturns the component of Type type in the GameObject or any of its children using depth first search. 返回Type類型組件,在GameObject或它的任何子物體使用深度優(yōu)先搜索,僅返回激活的組件。
  • GetComponentInChildren.<T>
  • GetComponentsInChildrenReturns all com
發(fā)表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發(fā)表
主站蜘蛛池模板: 麻豆小视频在线观看 | 国产精品av久久久久久网址 | 内地av在线 | 欧美在线观看视频网站 | 久久精品一二三区白丝高潮 | 最新欧美精品一区二区三区 | 国产分类视频 | 欧美羞羞视频 | 一区二区三区无码高清视频 | 欧美成人精品一区二区三区 | 一级黄色片武则天 | 91精品国产手机 | 国产亚洲精品精 | 亚州综合网 | 免费毛片小视频 | 黄色a级片视频 | 精品久久久久久久久亚洲 | 一区二区三区手机在线观看 | 成人在线视频播放 | 久久网国产| 亚洲一区二区三区日本久久九 | 在线中文字幕观看 | 久久久www视频| 国产在线免 | 精品国产乱码久久久久久丨区2区 | 精品国产乱码久久久久久久 | 日本在线视频一区二区三区 | 粉嫩粉嫩一区二区三区在线播放 | 欧美亚洲一级 | 一区二区视 | 国产成人强伦免费视频网站 | 亚洲卡通动漫在线观看 | 五月天影院,久久综合, | 欧美三级欧美成人高清www | 777zyz色资源站在线观看 | 久久精品a一级国产免视看成人 | 午夜小网站 | av在线更新 | 亚洲乱搞| 日日草视频 | 久久久久久久一区二区 |