
Python-Unity Network
Python 和 Unity 间通讯
https://github.com/Siliconifier/Python-Unity-Socket-Communication
https://github.com/Siliconifier/Python-Unity-Socket-Communication
用于将关键点数据转化为关节动作(各关节旋转角度)
希望机械臂的末端始终竖直。方便夹取。
Unity IK: https://github.com/2000222/Robotic-Arm-IK-in-Unity
自定义自由度,非常好用,基于关节梯度迭代的方法
由这个 IK 算法负责机械臂前三个 joint 的旋转,确保 j4 的 anchor(红点)处于物体后上方的特定位置。
j4 位置的计算方法:
1 | public Vector3 GetPositionForJ4(Vector3 pos) |
之后由向量计算得出 j4 应该旋转的角度,以确保末端竖直。
j5 不旋转,j6 的旋转角度由物体朝向决定。
一条路径由若干个关键点构成,在构建路径时只需输入若干 turning point,就会自行生成路径中的关键点。
1 | public class KeyPoint |
IK 只需要获取关键点的坐标信息就可以生成各个关节旋转的数据。
1 | InverseKinematics(GetPositionForJ4(position)); |
新的Input System:https://gamedevbeginner.com/input-in-unity-made-easy-complete-guide-to-the-new-system/#how_to_manage_input
目前的想法是将unity的physx和mujoco结合在一起,简化physx的对于相对运动很少的刚体间的物理解算。
Mujoco:https://mujoco.readthedocs.io/en/latest/unity.html
Besiege
需要更高的建造自由度:例如刚体零件的顶点自定义,3轴移动,3轴旋转,3轴缩放。
可视化内容更丰富:例如碰撞箱,连接点。
目前还是使用phsX引擎,考虑一下GPU加速这块功能。
零件之间的连接考虑使用joint以外的方式,特别是某些刚性连接。
参考我写的BesiegeModern Mod
{金属,木,玻璃}
需要自己写shader material实现该功能。
譬如撞击变形,高速击穿之类的
很难
在已有父刚体在运行中,更改碰撞箱布置是非常耗费性能的。
自定义场景元素
参考mc机械动力模组的“思索”
animation制作
起部分教程作用,添加沉浸感,吸引一些非硬核玩家
难,可能对电脑性能有较高要求。
unity shader
unity animation
美术相关工具
物理引擎Game Physics Engine Development
unity URP
.po
file for zh-en translationApply patches on the Initialize()
method in Db
class.
1 | public class Patches |
Take gold washer (just like water purifier but output small amount of gold) as an example.
1 | using System; |
Create a new csharp class file in VS and copy the content into it.
Remember to rename
id
in method CreateBuildingDef()
ID
in classGoldWasher
GeneratedBuildings
1 | using System; |
Only contain the control over control surface (on control over throttle)
Function: KeepPitch()
Control the angle of horizontal tail (elevator)
First keep the angle of elevator same with AoA(攻角), to avoid the disturbance of the horizontal tail on the attitide of the aircraft.
1 | aircraft.PitchAngle = aircraft.AoA; |
这里的aircraft.PitchAngle指的是飞机升降舵的角度(下片为正)
根据当前俯仰角,俯仰速度,和目标俯仰角,调整升降舵面的角度
1 | aircraft.PitchAngle += 5 * (p - aircraft.Pitch) / Mathf.Exp(10 * aircraft.PitchSpeed * Mathf.Sign(p - aircraft.Pitch)); |
与俯仰角类似(分别控制滚转舵面以及偏航舵面),不过不需要第一步
Control the thrust of aircraft to change the angle of gliding
保持飞机的俯仰角不变(5度仰角)
1 | KeepPitch(5f); |
计算当前下滑角
1 | float velAngle = 90 - Vector3.Angle(aircraft.rb.velocity, Vector3.up); |
根据下滑角更改油门大小
1 | aircraft.Thrust += (p - velAngle)/500f; |
通过调整飞机的下滑角来使飞机在竖直面上接近并维持在理想的下滑道
1 | Vector3 approachDirection = Vector3.ProjectOnPlane(route.Destination - transform.position, route.direction); |
1 | ThrustKeepGliding(-3 + Mathf.Clamp(approachDirection.y / 10f, -5,5)); |
通过调整飞机的偏航舵面角度(进而影响飞机的y轴rotation)来使飞机在水平面上接近并维持在理想的航道上
1 | Vector3 approachDirection = Vector3.ProjectOnPlane(route.Destination - transform.position, route.direction); |
1 | KeepYaw(-8 + Mathf.Clamp(distance / 10f, -50, 50)); |
基本的策略以及阐述完毕,那么所谓的理想下滑道到底应该怎么得到呢?
理想下滑道是一个射线,包含一个终点(飞机着陆的终点)和一个方向(飞机接近的方向)
1 | public class Target_Route |
理想航道的偏航角和下滑角已知(分别为-8(平行于着陆跑道)和-3)
通过迭代飞机着陆所需时间来求得下滑道终点的位置
1 | route.Destination = CV.transform.position; |
Starting point
The unity’s build-in physics engine PhysX is far from being precise enough for a vehicle simulator.
Through Asset Store
Starting point
The car model should be customizable, i.e. the user drag a car model into a directory and the game should be able to load it.
Filetype .glb is nice but unity doesn’t have build-in support
In tactics project:
1 | git submodule add https://github.com/Siccity/GLTFUtility.git ./Tactics/Assets/ThirdParty/GLTFUtility |
1 | using Siccity.GLTFUtility |
here I use Application.streamingAssetsPath+"/Model/"+JsonReader.vehicle.model.carBody[0].dir
as filepath
ArgumentNullException: Value cannot be null. Parameter name: shader
Save
and Model
folders?Application.streamingAssetsPath
, stands for Assets/StreamingAssets
in Unity editor and Game_Data/StreamingAssets
in exported game.First construct the structure of the json file in c#.
Notice: the name of the member variable should be the same with those in json file
1 | [System.Serializable] |
Notice: [System.Serializable]
is for serialized display in Unity editor.
Then, directly use build-in json loader:
1 | VehiclePara vehicle; |
All the parameters will be stored in the instance vehicle
.
1 | flowchart RL |
1 | { |
mod name: ModernAirCombat
1 | $createmod "ModernAirCombat" |
modify ./Mod.xml
1 | $createblock "ModernAirCombat" "SRAAM" |
1 | mkdir ./Resources/SRAAM |
add assets of SRAAM block r73.obj
, r73.png
modify ./Mod.xml
1 | <Mesh name="SRAAM Mesh" path="SRAAM\r73.obj"/> |
modify ./SRAAM.xml
create assembly for scripts
1 | createassembly "ModernAirCombat" compiled MacAssembly ModernAirCombat forceUnityTools |
open project with VStudio
edit ModernAirCombat.cs
1 | using System; |
add a block class SRAAM.cs
1 | using System; |
modify SRAAM.xml
1 | <Script>ModernAirCombat.SRAAMBlock</Script> |