u3d小知识记录

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类型,上面说的要理解到每一个轴上。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值