Fix visual slide issue with set_detach, fixes #5620
authorshivajiva101 <shivajiva101@hotmail.com>
Sat, 29 Apr 2017 16:18:46 +0000 (17:18 +0100)
committersfan5 <sfan5@live.de>
Sat, 29 Apr 2017 16:18:46 +0000 (18:18 +0200)
src/script/lua_api/l_object.cpp

index 9668f76f799c2df71e48786b7c065286025aec4a..a5b6e3941f58e68df011dd0c4b7e2df9051ee1bf 100644 (file)
@@ -726,11 +726,13 @@ int ObjectRef::l_set_detach(lua_State *L)
        v3f rotation;
        co->getAttachment(&parent_id, &bone, &position, &rotation);
        ServerActiveObject *parent = NULL;
-       if (parent_id)
+       if (parent_id) {
                parent = env->getActiveObject(parent_id);
-
+               co->setAttachment(0, "", position, rotation);
+       } else {
+               co->setAttachment(0, "", v3f(0, 0, 0), v3f(0, 0, 0));
+       }
        // Do it
-       co->setAttachment(0, "", v3f(0,0,0), v3f(0,0,0));
        if (parent != NULL)
                parent->removeAttachmentChild(co->getId());
        return 0;