Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Hover Force
- RaycastHit hit;
- bool grounded = false;
- for (int i = 0; i < hoverPoints.Length; i++)
- {
- var hoverPoint = hoverPoints [i];
- if (Physics.Raycast(hoverPoint.transform.position, -Vector3.up, out hit,hoverHeight, layerMask))
- {
- body.AddForceAtPosition(Vector3.up * hoverForce* (1.0f - (hit.distance / hoverHeight)), hoverPoint.transform.position);
- grounded = true;
- }
- else
- {
- // Self levelling - returns the vehicle to horizontal when not grounded
- if (transform.position.y > hoverPoint.transform.position.y)
- {
- body.AddForceAtPosition(hoverPoint.transform.up * gravityForce, hoverPoint.transform.position);
- }
- else
- {
- body.AddForceAtPosition(hoverPoint.transform.up * -gravityForce, hoverPoint.transform.position);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement