- Home /
How to use character controller to push down hinge joint properly
I am working with my finished Lerpz tutorial trying to learn about unity. What I am currently trying to do is make a hinged bridge which Lerpz can push down. The bridge will then rise when Lerpz isn't on it any more.
this is what the setup looks like:
-I used the crate mesh (only mesh) from "Build your Own!" in the project pane to make a Domino shape (by scaling down x-axis). Onto that mesh I added a boxcollider, a rigidbody and a hingejoint component (with no connected body).
I have encountered some problems which I hope you could help me with!
-I have trouble getting Lerpz to push it down (he understands the collision, but does not act upon it like a rigidbody). I have tried adding a rigidbody to "Player" and also "Player->Lerpz", but that doesn't work. How would you propose doing this in a beautiful manner?
What I've done to make it work is to make another rigidbody crate and use that as a child of "Player" to push down objects, but it just doesn't feel right :D
I appreciate any thoughts you got! /Z
Answer by Jaap Kreijkamp · Feb 18, 2010 at 11:52 PM
Just a quick thought, don't know if it really is the best way to do it but:
You could add a trigger on the bridge to detect Lerpz, then raycast a ray from lerps down to the bridge to calculate the hit point, then add a force to the bridge at this point.
I solved it, not using a trigger but raycasting from Lerpz to the bridge and using AddForceAtPoint. Since I have a spring on the bridge it is quite twitchy, so I have to find a good distance and angle for the ray to be cast(so i can stand on the bridge aswell). Thanks!