Quantcast
Channel: Questions in topic: "addforce"
Viewing all articles
Browse latest Browse all 1264

Issues when using Rigidbody force to Move/Carry Objects

$
0
0
Hi all, I am having some issues when changing my Object Carrying Method from a Static Locked position attached to the player to a more fluent movement that also has physics so carried objects cannot phase through walls etc. The issue I am facing while using this is that the object if placed under the Player and then picked up it levitates the player up into the sky, is there a way that while an object is being carried it ignores *only* the players collider, while still being able to crash into walls and other objects? ---------- The other issue I am having with this is that the object never seems to settle at the carry position, it always overshoots it's mark and is constantly 'bouncing' back and forth around the carrying position. ---------- The coding I am using to move the object toward its position while being carried is as follows: void moveObject() { if (isSmallOBJ) { if (transform.position != smallDest.position) { if(distance < 0.05f) { Vector3 f = smallDest.position - transform.position; f = f.normalized; f = f * lowForce; rig.AddForce(f); distance = Vector3.Distance(transform.position, smallDest.position); } else if (distance < 0.5f) { Vector3 f = smallDest.position - transform.position; f = f.normalized; f = f * midForce; rig.AddForce(f); distance = Vector3.Distance(transform.position, smallDest.position); } else if (distance < 5f) { Vector3 f = smallDest.position - transform.position; f = f.normalized; f = f * highForce; rig.AddForce(f); distance = Vector3.Distance(transform.position, smallDest.position); } else { dropObject(); } } } else { if (distance < 0.05f) { Vector3 f = dest.position - transform.position; f = f.normalized; f = f * lowForce; rig.AddForce(f); distance = Vector3.Distance(transform.position, dest.position); } else if (distance < 0.5f) { Vector3 f = dest.position - transform.position; f = f.normalized; f = f * midForce; rig.AddForce(f); distance = Vector3.Distance(transform.position, dest.position); } else if (distance < 5) { Vector3 f = dest.position - transform.position; f = f.normalized; f = f * highForce; rig.AddForce(f); distance = Vector3.Distance(transform.position, dest.position); } else { dropObject(); } } } ---------- Showcasing the Issues [Youtube Video][1] [1]: https://youtu.be/uU7Fz8XSsJM

Viewing all articles
Browse latest Browse all 1264

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>