diff --git a/src/obj/NiAVObject.cpp b/src/obj/NiAVObject.cpp index d83a7be9002826c7e8a20faf2b8779b88b86be45..46eecff67d7d4da1d7766906061cc601cb9152f5 100644 --- a/src/obj/NiAVObject.cpp +++ b/src/obj/NiAVObject.cpp @@ -338,10 +338,12 @@ Ref<NiCollisionObject > NiAVObject::GetCollisionObject() const { } void NiAVObject::SetCollisionObject( NiCollisionObject * value ) { - if ( value->GetTarget() != NULL ) { - throw runtime_error( "You have attempted to add a collision object to a NiAVObject which is already attached to another NiAVObject." ); + if ( value != NULL ) { + if ( value->GetTarget() != NULL ) { + throw runtime_error( "You have attempted to add a collision object to a NiAVObject which is already attached to another NiAVObject." ); + } + value->SetTarget( this ); } - value->SetTarget( this ); if ( collisionObject !=NULL ) { //Remove unlink previous collision object from this node