- Home /
Move object to raycast point.
OK, so essentially, I have script that emits a raycast forward from the camera, and moves grabbed objects to the hit-point. However, this presents the problem of the objects colliding into walls and into the floor when i release them.
I've tried displacing the position the grabbed object's position based on their extents, which works for cubic objects oriented towards the camera, pointed at flat walls, but not for any other situation.
As you can see, the picked up object is rendered on a layer above the standard camera layer.
My question is, how can i prevent the objects from being projected into positions where they would not fit, such as in corners, or through small gaps, or generally just walls and floors?
Answer by Brijs · Jun 09, 2016 at 02:05 PM
If i understood question correctly then cube shouldn't penetrate wall
So for that.......
Add rigidbody component to cube
Use rigidbody.Addforce()(In FixedUpdate() method) in direction(from gameObject to hit point) of hit point instead translating.
In rigidbody component set Collision Detection parameter to "Continuous" and Interpolate parameter to "Interpolate"
now cube will not penetrate wall corners, small gaps.
Answer by BrayanKrad03 · Jul 08, 2018 at 01:44 AM
Hi, this is an old post, but how you made that script? could you share it with me?
Answer by araz01 · Sep 27, 2018 at 05:19 PM
share the dam code alrdy... and if you wanna fix that, use vector3 lerp, so it happens overtime... come on... coding isnt about hiding, but showing... unless ur ea lol...
or what ever ur name is! Much Dove!