Jump to content

Recommended Posts

Posted

I am trying to put the case of my character having as reference the spindle of the nape of the neck, but it turns out that when he is falling into the void after a jump the case starts to float above his head, this using attach.

image.thumb.png.3c77d1ba6e3ee471900f900d702ae1e3.png

 

Now, if I use SetParent, to attach it to the mesh, whose root bone is in the middle of the legs, when falling the helmet does not move from its position.


image.thumb.png.53978aac60a80c871aa9e5fb967a6d1c.png

 

 

In such a case I need to position it in the head, in the Neck bone, and I have found a partial solution. 

image.thumb.png.145e6c51d6ba86f86f13baef4f15fb95.png

    function this:UpdateHelmet()
       
        helmet:SetPosition(0,0.12,-0.03)
        helmet:SetRotation(-20,0,0)
        helmet:Attach(ela,boneNeck)
       
    end
 
... self:UpdateHelmet() -- Run Ok.

 

 

 

Astrocuco.thumb.png.c76e0fb3de2d6e437e7dca099625e11e.png

Murphy's Law: We don't fix bugs, we document them as features. – Murphy Games

Posted

Does this start happening when the player is falling at a fast speed? Does it get worse the faster they are falling?

  • Like 1

My job is to make tools you love, with the features you want, and performance you can't live without.

Posted
2 hours ago, Josh said:

Does this start happening when the player is falling at a fast speed? Does it get worse the faster they are falling?

It happens after a jump, and gets worse when falling into the void.

 

 

Astrocuco.thumb.png.c76e0fb3de2d6e437e7dca099625e11e.png

Murphy's Law: We don't fix bugs, we document them as features. – Murphy Games

Posted
13 minutes ago, Yue said:

It happens after a jump, and gets worse when falling into the void.

Okay, I think the bone attachment code is probably running one frame behind the physics update. I should be able to move the place this happens and it will fix the problem.

  • Like 1

My job is to make tools you love, with the features you want, and performance you can't live without.

  • 2 weeks later...
Posted

imagen.thumb.png.4541bc2289976d7460f321495cf1969a.png

image.thumb.png.166f5d47efe3c16f722932e3d15f2479.png

Lo tengo dentro del bucle, pero sigue al personaje en el hueso de la cabeza, pero va como si fuera un helicóptero helice d eun girando sobre el hueso de la cabeza.

inicio heli GIF

 

imagen.thumb.png.5c36789963d12ff1b72c41a3db6f8ab6.png

 

 

Astrocuco.thumb.png.c76e0fb3de2d6e437e7dca099625e11e.png

Murphy's Law: We don't fix bugs, we document them as features. – Murphy Games

Posted

I thought the problem was that the attached object was trailing one frame behind, but the test case I created shows it working perfectly at high speeds.

#include "UltraEngine.h"

using namespace UltraEngine;

int main(int argc, const char* argv[])
{
    //Get the displays
    auto displays = GetDisplays();

    //Create a window
    auto window = CreateWindow("Ultra Engine", 0, 0, 1280, 720, displays[0], WINDOW_CENTER | WINDOW_TITLEBAR);

    //Create a framebuffer
    auto framebuffer = CreateFramebuffer(window);

    //Create a world
    auto world = CreateWorld();

    //Create a camera
    auto camera = CreateCamera(world);
    camera->SetClearColor(0.125);
    camera->SetFov(70);
    camera->Move(0, 2, -8);
 
    //Create light
    auto light = CreateBoxLight(world);
    light->SetRotation(45, 35, 0);
    light->SetRange(-10, 10);
    
    //Model by PixelMannen
    //https://opengameart.org/content/fox-and-shiba
    auto model = LoadModel(world, "https://github.com/UltraEngine/Documentation/raw/master/Assets/Models/Characters/Fox.glb");
    model->SetScale(0.05);
    model->Animate(1);
    model->SetRotation(0, -90, 0);

    auto neck = model->skeleton->FindBone("b_Neck_04");
    auto head = model->skeleton->FindBone("b_Head_05");
    Vec3 rotation;

    //Model by alissvetlana
    //https://sketchfab.com/3d-models/hat-a7f54e87bea94730b4a1827ec1f770df
    auto hat = LoadModel(world, "https://github.com/UltraEngine/Documentation/raw/master/Assets/Models/Characters/hat.glb");
    hat->SetScale(0.025);
    hat->SetPosition(-0.3, 0.4, 0);
    hat->Attach(model, head);

    //Main loop
    while (window->Closed() == false and window->KeyHit(KEY_ESCAPE) == false)
    {
        float move = 0;
        if (window->KeyDown(KEY_RIGHT)) move += 1;
        if (window->KeyDown(KEY_LEFT)) move -= 1;
        model->Translate(move, 0, 0);
        light->Translate(move, 0, 0);
        camera->Translate(move, 0, 0);

        window->SetText(model->position.x);

        world->Update();

        rotation.y = Cos(float(Millisecs()) / 10.0f) * 65.0f;
        neck->SetRotation(rotation);

        world->Render(framebuffer);
    }
    return 0;
}

 

  • Confused 1

My job is to make tools you love, with the features you want, and performance you can't live without.

Posted

 Ok, it's something here as I'm doing things, these weirdos just happen to me.  The mesh I load it in a sequence inside a loop, but to make it work for me I have to do this.


And it only goes inside the loop.


 

function this:UpdateHelmet()
        if helmet and boneNeck then
            helmet:SetPosition(0, 0.12, -0.03)
            helmet:SetRotation(-20, 0, 0)
            helmet:Attach(ela,boneNeck)
        end
    end
 
    function this:UpdteBackpack()
        if backpack and boneBack then
            backpack:SetPosition(0, -0.1,0.1)
            backpack:SetRotation(0, 0, 0)
            backpack:Attach(ela,boneBack)
        end
    end




image.thumb.png.59897832d46b7008db96b883cb686cd4.png

image.thumb.png.bc2a5a4f8722683d631dd3045ae2ebb4.png

 

 

Astrocuco.thumb.png.c76e0fb3de2d6e437e7dca099625e11e.png

Murphy's Law: We don't fix bugs, we document them as features. – Murphy Games

Posted

In each frame, so that it does not move when it falls into the void.

 

 

Astrocuco.thumb.png.c76e0fb3de2d6e437e7dca099625e11e.png

Murphy's Law: We don't fix bugs, we document them as features. – Murphy Games

Posted

That might be the cause of the problem. Maybe you should just attach it once?

My job is to make tools you love, with the features you want, and performance you can't live without.

Posted

But if I attach it only once, when falling into the void the helmet starts to rise and moves out of the character's position on his head. It is as if the controller is faster.

 

 

Astrocuco.thumb.png.c76e0fb3de2d6e437e7dca099625e11e.png

Murphy's Law: We don't fix bugs, we document them as features. – Murphy Games

Posted

I have done this, and it seems to go well, that is to say that for attach to work correctly I have to use it inside the loop so that the case does not fall off when the character is falling.

I think maybe that's what makes it attach internally.

 

image.thumb.png.99baa146357318d49716a2dbed68555f.png

function this:UpdateHelmet()
 
        local posBone = boneNeck:GetPosition(true)
 
        local pos = TransformPoint(posBone,ela,nil)
 
        helmet:SetPosition(pos,true)
 
        local rotBone = boneNeck:GetQuaternion(true)
 
        local rot  = TransformRotation(rotBone,ela,nil)
 
        helmet:SetRotation(rot,true)
 
        --if helmet and boneNeck then
        --  helmet:SetPosition(0, 0, 0)
        --  helmet:SetRotation(0, 0, 0)
        --  helmet:Attach(ela,boneNeck)
        --end
    end

 

 

Astrocuco.thumb.png.c76e0fb3de2d6e437e7dca099625e11e.png

Murphy's Law: We don't fix bugs, we document them as features. – Murphy Games

Posted

I need a working example I can run in order to test this.

  • Like 1

My job is to make tools you love, with the features you want, and performance you can't live without.

Posted

I have sent the project by inbox.


Ficle Script Lua.  Player.lua. 
 

    function this:UpdateHelmet()
 
        local posBone = boneNeck:GetPosition(true)
 
        local pos = TransformPoint(posBone,ela,nil)
 
        helmet:SetPosition(pos,true)
 
        local rotBone = boneNeck:GetQuaternion(true)
 
        local rot  = TransformRotation(rotBone,ela,nil)
 
        helmet:SetRotation(rot,true)
 
        --if helmet and boneNeck then
        --  helmet:SetPosition(0, 0, 0)
        --  helmet:SetRotation(0, 0, 0)
        --  helmet:Attach(ela,boneNeck)
        --end
    end
 
    function this:UpdteBackpack()
        if backpack and boneBack then
            backpack:SetPosition(0, -0.1,0.1)
            backpack:SetRotation(0, 0, 0)
            backpack:Attach(ela,boneBack)
        end
    end


on start.

   self:UpdateHelmet()
        self:UpdteBackpack()
        self:UpdteHelmetWaist()



On Update. 

   self:UpdateHelmet() 
        self:UpdteBackpack()
        self:UpdteHelmetWaist()

 

 

Astrocuco.thumb.png.c76e0fb3de2d6e437e7dca099625e11e.png

Murphy's Law: We don't fix bugs, we document them as features. – Murphy Games

Posted

I don't know how to make the bug appear.

I replaced UpdateHelmet with this code, and it works perfectly:

	function this:UpdateHelmet()
		--[[local posBone = boneNeck:GetPosition(true)
		local pos = TransformPoint(posBone,ela,nil)
		helmet:SetPosition(pos,true)
		local rotBone = boneNeck:GetQuaternion(true)
		local rot  = TransformRotation(rotBone,ela,nil)
		helmet:SetRotation(rot,true)]]
  
		if helmet and boneNeck and helmetattached ~= true then
			Notify("Attaching helmet now")
			helmetattached = true
			helmet:SetPosition(0, 0, 0)
			helmet:SetRotation(0, 0, 0)
			helmet:Attach(ela,boneNeck)
		end
	end

It also works fine if you attach the helmet each frame:

	function this:UpdateHelmet()
		helmet and boneNeck and helmetattached ~= true then
			--Notify("Attaching helmet now")
			--helmetattached = true
			helmet:SetPosition(0, 0, 0)
			helmet:SetRotation(0, 0, 0)
			helmet:Attach(ela,boneNeck)
		end
	end

My job is to make tools you love, with the features you want, and performance you can't live without.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...