c# - Rigid Body not colliding - Unity Project Tango -
i created rigidbody in unity3d , attached controller script control movement of body through tango motion control. problem reason, rigibody not collide walls have on side. passes through it.
here code snippet update()
void update() { debug.log("tango update: " + m_tangoposition + " " + m_tangorotation); poseprovider.getmouseemulation(ref m_tangoposition, ref m_tangorotation); transform.position = m_tangoposition + m_startposition; transform.rotation = m_tangorotation; } i tangopose data through onposeavailable call back
// pose callbacks project tango
public void ontangoposeavailable(tango.tangoposedata pose) { // nothing if don't pose if (pose == null) { debug.log("tangoposedata null."); return; } // callback pose device respect start of service pose. if (pose.framepair.baseframe == tangoenums.tangocoordinateframetype.tango_coordinate_frame_start_of_service && pose.framepair.targetframe == tangoenums.tangocoordinateframetype.tango_coordinate_frame_device) { if (pose.status_code == tangoenums.tangoposestatustype.tango_pose_valid) { // cache position , rotation set in update function. m_tangoposition = new vector3((float)pose.translation [0], (float)pose.translation [1], (float)pose.translation [2]); m_tangorotation = new quaternion((float)pose.orientation [0], (float)pose.orientation [1], (float)pose.orientation [2], (float)pose.orientation [3]); // debug.log("tango valid pose: " + m_tangoposition + " " + m_tangorotation); } } } am missing here ? why rigidbody go through walls? have attached script capsule rigidbody.
any or pointers appreciated.
thanks
you'll want make changes rigidbody position , rotation in fixedupdate method rather update. fixedupdate method used physics related changes , called @ fixed rate whereas update dependent on framerate.
furthermore, changing transform's position. teleporting object. if want move rigidbody , still have collision, check out moveposition , moverotation methods on rigidbody component.
i not know "tango" code similar following untested code:
public rigidbody rigidbody; void start() { rigidbody = getcomponent<rigidbody>(); } void fixedupdate() { //other code here rigidbody.moveposition(m_tangoposition + m_startposition); rigidbody.moverotation(m_tangorotation); } i hope have helped you!
Comments
Post a Comment