- Home /
Rigidbody MovePosition doesnt use continous dynamic setting
So basically I have a box with a non-trigger collider that has a non-kinematic rigidbody with continous dynamic setting enabled for the collision detection, and if I apply force to the rigidbody it works as intended: if it has a high velocity it still detects intermediate collisions and does not go through thin colliders. BUT if I don't use addforce (because I'm making an AI script thingy that should move more realisticly instead of just sliding on the ground like it has skates or something), instead I use Rigidbody.MovePosition with the exact same setup with the cube and the wall the cube just goes through it if I set the movespeed to about like a running speed (works mostly fine if it has a small speed but still kinda goes into the wall). SO MY QUESTION IS: Is there a way to enable continous collision detection for the Rigidbody.MoveRotation (I mean like MoveRotation(DestPos,true); would be very useful), or is there a workaround with the results I'm looking for with like playing with addforce and stuff?
Here is the script btw:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class MovePosTester : MonoBehaviour {
// Use this for initialization
void Start () {
}
// Update is called once per frame
void FixedUpdate () {
if(Input.GetKey(KeyCode.K)){
GetComponent<Rigidbody> ().MovePosition (transform.position + transform.forward * Time.fixedDeltaTime * 40.0f);
}
}
}
And here are a the evidences :) : https://media.giphy.com/media/vcqhN9i2r2iaSfN818/giphy.gif
Have you tried using Debug.Log to check if transform.position of the object is correctly registered each frame?
I tried the rigidbody's position but it still doesn't work and if something would be correctly registered than it would be that. And if the transform's position wouldn't be correctly registered why would that be? What would cause such a thing and how to fix it? (btw I found a solution with adding a force like this: AddForce(desiredforce - rigidbody.velocity * 9); but this makes it much harder to push my mobs around on the ground, but at least they aren't skating around and falling off cliffs. I would still like to find a better solution for this tho.)
Answer by Arqae · Aug 24, 2019 at 03:20 PM
Way out in the future, but if you found a solution i would be happy to know :)
@Arqae No, I didn't really touch that project since, I guess a dirty solution would be using a capsule, box or sphere collider on the object and doing a Physics.CapsuleCast, BoxCast or SphereCast in the direction that the object is moving in, and see where it would hit the wall and stop it there, or do a Rigidbody.SweepTest maybe
Your answer
Follow this Question
Related Questions
How to make Rigidbody.AddForce less delayed in Unity3D? 0 Answers
Cancelling Force of Rigidbody for new Direction 2 Answers
ball's collider sometimes catches an edge and bounces. when ball rolls over two aligned platforms 1 Answer
Object jumps right after the attached HingeJoint2D is Enabled 0 Answers
Script isn't consistent 0 Answers