The game often encounters a battle on the mobile, and unity's rigid body is strange and will fall directly
Default condition:
The easy way is to set the parent object
But to be inquisitive, dragging in unity, using transform to move, is not actually a physical move
Only change the rate is, and later with the constant force to test a bit, sure enough to drive the object standing above
So, I tried the simpler way :
Script:
usingUnityengine;usingSystem.Collections; Public classphysicstest:monobehaviour{Const intMax_mass =10000; voidAwake () {getcomponent<Rigidbody> (). Mass =Max_mass; Getcomponent<Collider> (). Material =Newphysicmaterial (); Getcomponent<Collider> (). Material.staticfriction =99999; Getcomponent<Collider> (). Material.dynamicfriction =99999; } IEnumerator Start () { while(true) { for(inti =0; I < -; i++) {getcomponent<Rigidbody> (). Velocity = vector3.right * Time.deltatime *1000f; yield return Newwaitforfixedupdate (); } yield return NewWaitforseconds (1); for(inti =0; I < -; i++) {getcomponent<Rigidbody> (). Velocity =-vector3.right * Time.deltatime *1000f; yield return Newwaitforfixedupdate (); } yield return NewWaitforseconds (1); } }}View Code
This can be used in the horizontal version of the game is very convenient to avoid a lot of bugs
But for the 3D game of the aircraft or train on the top of the mobile is more troublesome, the driving mode of the carrier is very complex, or to change the parent object is better
Questions about standing on a moving object