unity 3.3, create local gravity on object

放肆的年华 提交于 2019-12-06 10:24:15

what you can do is add a collision box that unity has as a component to add to any gameObjects and then you check if anything enters that collision box and add force to the object that is colliding. i will get you sample code if needed.

//edit

you can add your own gravity to a script and have your own function for adding force to make it move in a direction but just so you know you can change how much gravity a rid. body does

but if you want to do your own gravity you can do

bool grounded = false;

void gravity(){

    gameObject.trasform.position.x -= gravity

}

void onCollisionEnter(collision c){
     //check and see what you are colliding with and if its the ground then set grounded to true and that will get you falling gravity. there is more you can do for more adv. gravity but ill leave that up to you
}

edit*

if i get what your saying about sticking to an object what you need to do is make the object the parent of the object that needs to stick to it

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!