当前位置:网站首页>D46_Force applied to rigid body
D46_Force applied to rigid body
2022-08-05 06:32:00 【It's not that simple GG】
Rigidbody r;public int F;private void Start(){r = GetComponent();r.AddForce(Vector3.forward * F, ForceMode.Force);//v = f*t/m;//Add a continuous force and use mass//Objects of different masses move at different speeds//The object eventually moves at a uniform speed, and the speed is related to the magnitude of the force and the mass of the rigid bodyr.AddForce(Vector3.forward * F, ForceMode.Impulse);//v = f*t/m;//Add a momentary force and use mass//Objects of different masses move at different speeds//The object eventually moves at a uniform speed, and the speed is related to the magnitude of the force and the mass of the rigid bodyr.AddForce(Vector3.forward * F, ForceMode.VelocityChange);//v = f*t/m;//Add a momentary force, ignoring mass//The object eventually moves at a uniform speed, and the speed is only affected by the magnitude of the forcer.AddForce(Vector3.forward * F, ForceMode.Acceleration);//v = f*t/m;//Add a continuous force, ignoring mass//The object eventually moves at a uniform speed, and the speed is only affected by the magnitude of the forcer.AddTorque(Vector3.forward * F, ForceMode.Force);//Add torque (world orientation)r.AddRelativeForce(Vector3.forward * F, ForceMode.Force);//Add force (self direction)r.AddRelativeTorque(Vector3.forward * F, ForceMode.Force);//Add torque (self direction)} A question:
Requires a bomb explosion effect
public float radius;public float force;void Update(){if (Input.GetKeyDown(KeyCode.Space)){//Find all Colliders within the explosion range and add a Layer to the objects that need to add forceCollider[] col=Physics.OverlapSphere(transform.position,radius,1<<8);for (int i = 0; i < col.Length; i++){// Find the direction between the bomb and each game objectVector3 dir = (col[i].transform.position - transform.position).normalized;//Maximum explosive force closest to the bomb = force Minimum force away from the bomb beyond radius (explosion radius) = 0//The farther the distance is, the smaller the impact force the game object receives. The greater the distance, the smaller the t.float t = 1 - (Vector3.Distance(transform.position,col[i].transform.position)/radius);//t is limited between 0 and 1t=Mathf.Clamp(t,0,1);float finalForce = Mathf.Lerp(0,force,t);//Add an instantaneous, mass-influenced forcecol[i].GetComponent().AddForce(dir*finalForce,ForceMode.Impulse);}}} 边栏推荐
- 正则表达式小示例--获取重复最多的字符及其数量
- 七种让盒子水平垂直居中的方法
- Teach you simple steps to achieve industrial raspberries pie properly installed RS232 USB drive
- What impact does CIPU have on the cloud computing industry?
- 网络不通?服务丢包?看这篇就够了
- Wechat applet page jump to pass parameters
- ROS2下使用ROS1 bag的方法
- markdown编辑器模板
- time complexity and space complexity
- 请问下通过flink sql读取hologres 的两张表的 binlog,然后如何进行join?
猜你喜欢
![[问题已处理]-jenkins流水线checkout超时](/img/3d/c14276d2b5ce18fc3d1288abb059c0.png)
[问题已处理]-jenkins流水线checkout超时

网络不通?服务丢包?看这篇就够了

Problems encountered in installing Yolo3 target detection module in Autoware

Mina's long and short connections
time complexity and space complexity

ALC实验

Passing parameters in multiple threads

多线程之传递参数

Teach you simple steps to achieve industrial raspberries pie properly installed RS232 USB drive

Complete mysql offline installation in 5 minutes
随机推荐
This is indeed the best article on microservice architecture I have read!
VLAN介绍与实验
spark operator-parallelize operator
NAT experiment
link 和@improt的区别
路由器和静态路由的配置
Autoware--Beike Tianhui rfans lidar uses the camera & lidar joint calibration file to verify the fusion effect of point cloud images
From "dual card dual standby" to "dual communication", vivo took the lead in promoting the implementation of the DSDA architecture
flink cdc 目前支持Gauss数据库源吗
transport layer protocol
逻辑卷创建
实力卷王LinkSLA,实现运维工程师快乐摸鱼
带你深入了解Cookie
Browser Storage for H5
Next-Generation Parsing Technology - Cloud Parsing
Vim tutorial: vimtutor
网络不通?服务丢包?看这篇就够了
Switch principle
传输层协议
I/O performance and reliability