1、
Transform.forward 向前
The blue axis of the transform in world space.在世界空间坐标变换的蓝色轴。也就是z轴。
就是物体在局部坐标系的z轴在世界坐标系中的值,而而Vector3.forward只不过是(0, 0, 1)的缩写
using UnityEngine;
using System.Collections;
public class example : MonoBehaviour
{
public void Awake()
{
// Set's the rigidbody velocity to be
// along the blue axis of the transform
//设置刚体的速度沿着物体的蓝色轴移动
rigidbody.velocity = transform.forward * 10;
}
}
using UnityEngine;
using System.Collections;
// Computes the angle between the target transform and this object
//计算目标变换和这个物体之间的角度
public class example : MonoBehaviour
{
public float angleBetween = 0.0F;
public Transform target;
void Update()
{
Vector3 targetDir = target.position - transform.position;
angleBetween = Vector3.Angle(transform.forward, targetDir);
}
}
2、
Quaternion 是四元数,平时说有x,y,z,w这四个值,但是这里的xyz并非是三个角度值,unity中在检视面板显示的是欧拉角,和这里的四元数是两个概念,这里的x,y,z,w只有一起使用时才有意义,也不需要关心每个值代表什么,在unity中知道Quaternion 有关的几个重要函数,足够了(来自网络)
3、
Message相关有3条指令:SendMessage ("函数名",参数,SendMessageOptions) //GameObject自身的Script
BroadcastMessage ("函数名",参数,SendMessageOptions) //自身和子Object的Script
SendMessageUpwards ("函数名",参数,SendMessageOptions) //自身和父Object的Script
4、
ForceMode
Description
Option for how to apply a force using Rigidbody.AddForce.
Variables
Force | Add a continuous force to the rigidbody, using its mass.考虑质量的加速度,Rigidbody.AddForce的Force值为1时,质量1的物体加速度1m/s^2,质量2的物体加速度0.5m/s^2 |
Acceleration | Add a continuous acceleration to the rigidbody, ignoring its mass.不考虑质量的加速度,Rigidbody.AddForce的Force值(不要理解成力)为1时,任何质量的物体加速度1m/s^ |
Impulse | Add an instant force impulse to the rigidbody, using its mass.考虑质量的速度变化,Rigidbody.AddForce的Force值(不要理解成力)为1时,质量1的物体速度+1m/s,质量2的物体速度+0.5m/s |
VelocityChange | Add an instant velocity change to the rigidbody, ignoring its mass.不考虑质量的速度变化,Rigidbody.AddForce的Force值(不要理解成力)为1时,任何质量的物体速度+1m/s Rigidbody.AddForce的Force为Vector3类型,上面说的要理解到每一个轴上。 |