|
hi, I understand that Unity's Gravity calculation for Rigidbodies is quite expensive for mobiles devices. I was wondering if there is a work-around to this, possibly a script simulating the same effect / acceleration?
(comments are locked)
|
|
Calculating gravity effects is the cheapest part - the big problem comes from collision detection and reaction to collisions, other tasks that the management of a rigidbody requires.
var velocity: Vector3 = Vector3(5, 5, 0);
var gravity: float = 9.8;
function Update(){
velocity.y -= gravity * Time.deltaTime; // apply gravity
transform.position += velocity * Time.deltaTime; // calculate new position
}
This simple code will make the object to which it's attached to describe a ballistic trajectory. Collisions aren't detected, but maybe a good compromise could be achieved by adding a kinematic rigidbody to the object and setting its collider to trigger, then using OnTriggerEnter to detect collisions.
(comments are locked)
|
