Vida Marcell Posted December 14, 2021 Share Posted December 14, 2021 I want to make a player that has animated movement with ik foots, how should i do that in leadwerks? like an assasins creed with fps camera. Quote Link to comment Share on other sites More sharing options...
Yue Posted December 14, 2021 Share Posted December 14, 2021 Do you mean that if the character is on a staircase his feet accommodate each step where he places his feet? Quote Link to comment Share on other sites More sharing options...
Vida Marcell Posted December 14, 2021 Author Share Posted December 14, 2021 Just now, Yue said: Do you mean that if the character is on a staircase his feet accommodate each step where he places his feet? Yes Quote Link to comment Share on other sites More sharing options...
Yue Posted December 14, 2021 Share Posted December 14, 2021 The only thing I can think of is to have a beam coming out of each player's foot and these detect when the player touches the ground. If one doesn't touch the ground depending on the leg it could trigger an animation that is one foot lower. Possibly there is another better way to do it. Quote Link to comment Share on other sites More sharing options...
Vida Marcell Posted December 14, 2021 Author Share Posted December 14, 2021 2 minutes ago, Yue said: The only thing I can think of is to have a beam coming out of each player's foot and these detect when the player touches the ground. If one doesn't touch the ground depending on the leg it could trigger an animation that is one foot lower. Possibly there is another better way to d This is smart. But i think i will focus on blending the animations. Integrating havok would help. but if someone notices it Havok will beat my ***. Quote Link to comment Share on other sites More sharing options...
Vida Marcell Posted December 14, 2021 Author Share Posted December 14, 2021 Also how in the hell can i attach a cpp code to a character? Quote Link to comment Share on other sites More sharing options...
Charrua Posted December 14, 2021 Share Posted December 14, 2021 HI, you can attach a lua script from the editor. If you have the profesional edition and you are using VSxxx and cpp you may interact with world elements created on the editor, call lua functions in the object's script, pass parameters, receive etc. I wrote this some time ago, don't know how much outdated it may be, but perhaps it will be a starting point: Juan 2 Quote Paren el mundo!, me quiero bajar. Link to comment Share on other sites More sharing options...
Vida Marcell Posted December 14, 2021 Author Share Posted December 14, 2021 1 minute ago, Charrua said: HI, you can attach a lua script from the editor. If you have the profesional edition and you are using VSxxx and cpp you may interact with world elements created on the editor, call lua functions in the object's script, pass parameters, receive etc. I wrote this some time ago, don't know how much outdated it may be, but perhaps it will be a starting point: Juan Thank you very much! Quote Link to comment Share on other sites More sharing options...
Yue Posted December 14, 2021 Share Posted December 14, 2021 I believe there is a FindEntity command in the current world. ( map ) and another called SetScript. Quote Link to comment Share on other sites More sharing options...
Vida Marcell Posted December 15, 2021 Author Share Posted December 15, 2021 Last thing, how can i make my crouch more fluid? Quote Link to comment Share on other sites More sharing options...
Slastraf Posted December 15, 2021 Share Posted December 15, 2021 12 hours ago, Vida Marcell said: Last thing, how can i make my crouch more fluid? you need this to be a function with a tick and for every tick your camera moves a tiny bit more towards the target position. You could use Lerp in that function : https://www.leadwerks.com/learn?page=API-Reference_Object_Math_Lerp 1 Quote Link to comment Share on other sites More sharing options...
Vida Marcell Posted December 15, 2021 Author Share Posted December 15, 2021 2 minutes ago, Slastraf said: you need this to be a function with a tick and for every tick your camera moves a tiny bit more towards the target position. You could use Lerp in that function : https://www.leadwerks.com/learn?page=API-Reference_Object_Math_Lerp Good solution, thanks! 1 Quote Link to comment Share on other sites More sharing options...
Vida Marcell Posted December 16, 2021 Author Share Posted December 16, 2021 Is this the right way of doing it? camera->SetPosition(0, Math::Lerp(1, -0.4, 0.5), 0); Because its not working for me. Quote Link to comment Share on other sites More sharing options...
Slastraf Posted December 16, 2021 Share Posted December 16, 2021 //might not work but is pseudo code // Vec3 ccamerapos = ccamera->GetPosition(); // ccamera->SetPosition(0, Math::Lerp(1, ccamerapos->GetY(), (crouchedBool*(characterheight)+crouchHeight 0); Quote Link to comment Share on other sites More sharing options...
Vida Marcell Posted December 16, 2021 Author Share Posted December 16, 2021 2 minutes ago, Slastraf said: //might not work but is pseudo code // Vec3 ccamerapos = ccamera->GetPosition(); // ccamera->SetPosition(0, Math::Lerp(1, ccamerapos->GetY(), (crouchedBool*(characterheight)+crouchHeight 0); man, thank you, lemme check if its working Quote Link to comment Share on other sites More sharing options...
Vida Marcell Posted December 17, 2021 Author Share Posted December 17, 2021 Allright, can someone tell what am i doing wrong here is a part of my code: //Load a prefab Entity* player = Prefab::Load("Prefabs/player.pfb"); player->SetPosition(0, 6, 0); player->SetSweptCollisionMode(true); Camera* camera = Camera::Create(player); camera->SetPosition(0, 2, 0); float playerheight; window->HideMouse(); float walk; float turn; float jump; float jumpspeed = 8; float speed; bool cdown = 0; Vec3 mouse = Vec3(0, 0, 0); Vec3 velo = Vec3(0, 0, 0); Vec3 camera_y = Vec3(0, 0, 0); float mouse_x; float mouse_y; float lerp; while (true) { camera->GetPosition(); camera_y = camera->GetPosition(); mouse = window->GetMousePosition(); window->SetMousePosition(window->GetWidth() / 2, window->GetHeight() / 2); mouse_x += (mouse[0] - window->GetWidth() / 2) / 4.5; mouse_y += (mouse[1] - window->GetHeight() / 2) / 4.5; camera->SetRotation(mouse_y, 0, 0); walk = window->KeyDown(Key::W) *speed - window->KeyDown(Key::S) *speed; turn = window->KeyDown(Key::D) *speed - window->KeyDown(Key::A) *speed; speed = 5 + window->KeyDown(Key::Shift) * 2 - window->KeyDown(Key::Control) * 3.5; lerp = Math::Lerp(2, 0, 0.5); if (!window->KeyDown(Key::ControlKey) && cdown == 1) { cdown = 0; speed = 8.0; camera->SetPosition(0, 1.75, 0); } if (window->KeyDown(Key::ControlKey) && cdown == 0) { cdown = 1; speed = 4.0; camera->SetPosition(0, lerp, 0); } velo = player->GetVelocity(); if (velo[1] == 0.0) { jump = window->KeyHit(Key::Space) * jumpspeed; } else { jump = window->KeyHit(Key::Space) * 0.0; } player->SetInput(mouse_x, walk, turn, jump, cdown, 1, 1, true); if (window->Closed() || window->KeyDown(Key::Escape)) return false; Leadwerks::Time::Update(); world->Update(); world->Render(); context->Sync(); } return 0; } Quote Link to comment Share on other sites More sharing options...
Slastraf Posted December 17, 2021 Share Posted December 17, 2021 lerp = Math::Lerp(2, 0, 0.5); will always make the player height zero lerp = Math::Lerp(camera->GetPosition().y, (playerheight*cdown ), 0.5); does this make sense to you ? camera->GetPosition().y, may be wrong but you need to get the y part of the vector of getposition also you need to remove (makes no sense): while (true) { // remove this line camera->GetPosition(); 1 1 Quote Link to comment Share on other sites More sharing options...
Vida Marcell Posted December 17, 2021 Author Share Posted December 17, 2021 Man, thanks for your help! If you need models or something for your game, just call me. I think i can make it work. 1 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.