在物理世界中,让子弹的刚体受到一个冲量,就可以简单的实现子弹的飞行。
Body.AddForce(Direction * Froce , ForceMode.Impulse);
而ForceMode.Impulse:此种方式采用瞬间力作用方式,即把t的值默认为1,不再采用系统的帧频间隔,即
f•1.0=m•v
那么v=f/m
如果射击的物体是移动的,那刚体的初速度则为射击物体的速度。
故v=v0+f/m
最近遇到一个需求,已知初速度和冲量,要绘制出子弹的轨迹。
如下图效果:
考虑把它分成x轴和y轴的运动。
即,在x轴上匀速运……继续阅读 »
11年前 (2016-06-06) 3133浏览 0评论
0个赞
AddComponentMenu
添加组件菜单(可以在UnityEditor的Component的Menu中增加自定义的项目)
[AddComponentMenu("Transform/Follow Transform")]
AssemblyIsEditorAssembly
汇编级属性,使用该属性的Class会被认为是EditorClass
ColorUsageAttribute
用于配置颜色和颜色选择
ContextMenu
可以在Inspector的ContextMenu中增加选项
[ContextMenu……继续阅读 »
11年前 (2016-06-03) 2950浏览 0评论
0个赞
指定可以对它们应用特性的应用程序元素
成员名称
说明
All
可以对任何应用程序元素应用属性。
Assembly
可以对程序集应用属性。
Class
可以对类应用属性。
Constructor
可以对构造函数应用属性。
Delegate
……继续阅读 »
11年前 (2016-05-27) 2365浏览 0评论
0个赞
为了从资源上优化安装包的大小,写了一个工具
点击查找,列出所以文件,并按从大到小的顺序排序
先上一下效果图
/// <summary>
/// 定义文件结构体
/// </summary>
public struct FileAttribute
{
public string path; //路径
public long size; /……继续阅读 »
11年前 (2016-05-27) 3355浏览 0评论
0个赞
public static bool IsEnableTouchLayer(Camera cameraSeeTheLayer, string layer)
{
bool r = false;
string strLayer = "";
Vector3 posMouse = Input.mousePosition;
posMouse.z = 10;
Ray ray = cameraSee……继续阅读 »
11年前 (2016-05-06) 2610浏览 0评论
0个赞
public static string timeStampToString(int time)
{
long ltime = (long )time;
DateTime t = new DateTime(time * TimeSpan.TicksPerSecond);
t = t. ToLocalTime();
int year = t.Year + 1969 ;
string syear = "" + year;
int month = t.Month ;
string smonth = month < 10……继续阅读 »
11年前 (2016-04-27) 2679浏览 0评论
0个赞
假设有一个怪物类Monster,Monster中包含跑、跳、走、爬等属性。
定义:
static const int a = 1; //跑 1
static const int b = 1 << 1; //跳 10
static const int c = 1 << 2; //走 100
static const int ……继续阅读 »
11年前 (2016-04-27) 2356浏览 0评论
0个赞
配置文件:battleRes.json
{
"png": [
"sprite/heroSpecialEffect1.png",
"sprite/heroSpecialEffect2.png",
"sprite/planeLine.png",
"sprite/sky_bg.png",
"sprite/superReward1.png",
"sprite/superReward2.png",
……继续阅读 »
11年前 (2016-04-27) 3848浏览 0评论
0个赞
不少公司的网管试图解决双网卡问题,下面我就给大家详细的讲解一下双网卡同时使用的方法,这样即可保障内网的安全,又能解决电脑访问外网的问题,一举两得。希望大家喜欢。
首先你的机器需要有两块网卡,分别接到两台交换机上,
internet地址:192.168.1.8,子网掩码:255.255.255.0,网关:192.168.1.1
内部网地址:172.23.1.8,子网掩码:255.255.255.0,网关:172.23.1.1
如果按正常的设置方法设置每块网卡的ip地址和网关,再cmd下使用route print查……继续阅读 »
11年前 (2016-04-27) 2860浏览 0评论
0个赞
public void Update()
{
if (Input.GetMouseButton(0))
{
Vector3 pos = UICamera.currentCamera.ScreenToWorldPoint(Input.mousePosition);
test.transform.position = pos;
}
}
……继续阅读 »
11年前 (2016-04-08) 4409浏览 2评论
0个赞