Playmaker Forum

PlayMaker Help & Tips => PlayMaker Help => Topic started by: SawyerK on January 19, 2020, 11:54:12 AM

Title: Rigidbody goes through wall/terrain
Post by: SawyerK on January 19, 2020, 11:54:12 AM
When i pick up a rigidbody (parenting to playercamera) i turn its gravity off and get its localposition then write it back every frame with setPosition to keep it in the parented position.I don't use isKinematic. The problem is the object still goes through walls and terrain. They have collision.
Title: Re: Rigidbody goes through wall/terrain
Post by: djaydino on January 19, 2020, 01:09:09 PM
Hi.
i am not sure what you mean, but when you disable gravity on a object its bets to do a set velocity right after you set gravity to 0

can you show a video or some images?
Title: Re: Rigidbody goes through wall/terrain
Post by: SawyerK on January 19, 2020, 07:02:59 PM
Sure. I do use setVelocity and setAngularVelocity, both set to 0 and i use getPosition and setPosition so the object stays in front of the camera, it looks like that the picked up object collides with the wall/ground when it touches it but it still goes through. :D
(https://i.postimg.cc/rpsf5hCj/gtw1.jpg)
(https://i.postimg.cc/LsWNDzxp/gtw2.jpg)
(https://i.postimg.cc/HnD3DTGv/gtw3.jpg)
(https://i.postimg.cc/3RD9cdqD/gtw4.jpg)
(https://i.postimg.cc/j2HcRBtx/gtw5.jpg)
Title: Re: Rigidbody goes through wall/terrain
Post by: djaydino on January 20, 2020, 03:57:55 AM
Hi,
I did i quick google search and this might get you in the right direction :

https://answers.unity.com/questions/1195454/rotating-gameobject-not-colliding-1.html
Title: Re: Rigidbody goes through wall/terrain
Post by: SawyerK on January 20, 2020, 08:13:53 AM
Thanks, but it still goes through even if i use angularVelocity to rotate, i think the problem going to be the setPosition, but i dont know how to set the objects position withouth setPosition.
Title: Re: Rigidbody goes through wall/terrain
Post by: SawyerK on January 20, 2020, 08:32:08 AM
I tried using moveTowards which works for bigger objects, but even that's not perfect smaller object like a handgun goes through wall/ground.
Title: Re: Rigidbody goes through wall/terrain
Post by: DanielThomas on January 20, 2020, 08:54:03 AM
Since it's physics, make sure you're using Rigidbody set position.
Title: Re: Rigidbody goes through wall/terrain
Post by: SawyerK on January 20, 2020, 09:52:40 AM
The rigidbody setPosition doesn't have a self "Space" it only uses world space.
Title: Re: Rigidbody goes through wall/terrain
Post by: DanielThomas on January 21, 2020, 05:16:23 AM
If you want accurate physics emulation(which seems like your problem from initial post) you should use Rigidbody.
Title: Re: Rigidbody goes through wall/terrain
Post by: SawyerK on January 21, 2020, 09:10:49 AM
It is a rigidbody.
Title: Re: Rigidbody goes through wall/terrain
Post by: DanielThomas on January 21, 2020, 11:53:54 AM
I mean Rigidbody actions. This is the absolute first thing I would try considering using transform position doesn't use physics and can lead to things like colliders going through colliders.