Questions about standing on a moving object

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.