how to stop colliders in a collision while using kinematic ways instead of physical ways?

Hello everyone! Here I have 3 items, a CharacterController, a Box and a Wall. I let the Controller to hit the Box making it move away using kinematic ways (e.g. directly editing its Transform.position).


But now I have a problem that if the Box hits the Wall after its being hit by the Controller and moving away, it will stay for a while and then rebound away because it can’t pass through the Wall.


I know it’s natural to stop the Box if I use physical ways in the Box’s moving instead of using kinematic ways. So my quesion is how to stop the Box in the collision while using kinematic ways instead of physical ways?

To do it properly you would have to write your own physics system to calculate what would happen if the velocity was applied the way it should be, then apply the result to your cube. Why not just do it "the physical way" in the first place?

because I want the Box to move a certain distance. If I apply the "physical way" in the first place, can u tell me how to make the Box move a certain distance?

well I would do it on trigger enter collider other kinematic = true; it'll stop exactly at that point and become kinematic if you need code to be provided tell me

@sdgd sure, post ur code and let's discuss it.

1 Answer

1

this is how I’d do it and as soon as object with tag: “you wanna strict to this tag” and will come in by force will stop.

kinematic never listens to forces

if it’s anything else that’s dragging you need to catch it inside with get component and disable that script and let me know if you need that too

using UnityEngine;
using System.Collections;

public class NewBehaviourScript : MonoBehaviour {
	void OnTriggerEnter (Collider Other){
        Debug.Log("We're in");
		if (Other.tag == "you wanna strict to this tag"){
			Other.rigidbody.isKinematic = true;
		}
	}
}

and OFC this has to be on a wall

extend the collider for 0.5 more ofc don't forget to accept the answer you are most satisfied for your question do not forget this is not discussion it's Q/A if you have sub questions you should open new question you have [FAQ][1] on the right and maybe your next question should be wider Question of what you want to achieve and provide more information and how you are handling the situation. [1]: http://answers.unity3d.com/page/faq.html