Roberto14 Posted December 21, 2016 Share Posted December 21, 2016 Hi all, i have a simply request: I can i instantly stop ( remove every force ) an entity that is moved with physic simulation?? Actually, considering i'm using SetInput to move my entity, if i jump and disable gravity i'll go far away. It's beautifull ( ) but i need the possibility to stop my entity in the air by pressing a key. How can i achieve this? Quote I'm not english, so please sorry for my grammatical errors I'm using Leadwerks and can programm in C++ and LUA Link to comment Share on other sites More sharing options...
gamecreator Posted December 21, 2016 Share Posted December 21, 2016 Have you already tried setting SetVelocity to 0? Also, a hacky way might be to set the mass to 0 since if I remember right, an object needs a mass to work with physics. For SetInput there's Stop. These are just options but I don't know how instant any of them are. Documentation is here. 1 Quote Link to comment Share on other sites More sharing options...
Josh Posted December 21, 2016 Share Posted December 21, 2016 SetVelocity should do it. Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
Roberto14 Posted December 22, 2016 Author Share Posted December 22, 2016 Result are Stop doesn't affect remaining forces and with SetVelocity i got crash, because of some internal error: Symply i jump and when player land over terrain should stop, immediately. Quote I'm not english, so please sorry for my grammatical errors I'm using Leadwerks and can programm in C++ and LUA Link to comment Share on other sites More sharing options...
Roberto14 Posted December 22, 2016 Author Share Posted December 22, 2016 My pEntity is created in this way: pEntity = Leadwerks::Pivot::Create(); pEntity->SetMass( 80 ); pEntity->SetPosition( Position ); --> vector pEntity->SetRotation( Rotation ); --> vector pEntity->SetPhysicsMode( Leadwerks::Entity::CharacterPhysics ); pEntity->SetCollisionType( Leadwerks::Collision::Character ); pEntity->SetShadowMode( 0 ); pEntity->SetPickMode( 0 ); pEntity->SetFriction( 0.0, 0.0 ); pEntity->SetMaterial( "Materials\\Effects\\Invisible.mat" ); Quote I'm not english, so please sorry for my grammatical errors I'm using Leadwerks and can programm in C++ and LUA Link to comment Share on other sites More sharing options...
Roberto14 Posted December 23, 2016 Author Share Posted December 23, 2016 (edited) The iter in my program is: using SetInput to move my player, on a trigger i disable entity gravity and then i use Move to manually move my entity along his axis. The my problem are residual forces from last call of SetInput that on SetGravityMode call still persist, and allow my entity move in the air. However i cannot set mass to 0 because i need physic for collision, because when my entity reach a particolar model, on collide then i reset gravity. Setting mass to 0 i cannot get physical interactions. Edit: I have done some tests One case is really strange: in my cpp class i create my entity with mass 80, now in my trigger script, at function Script:Collision( entity, Position, Normal, Speed ) whith this call: entity:SetMass( 80 ); entity:SetVelocity( 0.0, 0.0, 0.0 ); entity:SetGravityMode( false ); i doesn't get any effects and any crash, if i remove SetMass: entity:SetVelocity( 0.0, 0.0, 0.0 ); entity:SetGravityMode( false ); then i get crash, like in previous screen. Edit Edit I read here: The tradeoffs are inevitable and this is why I coded my own in my last tournament entry. Not to say that there aren't solutions to your problems but I don't know any. That said, I thought SetVelocity did work on character controllers. I could have sworn I used it to push back enemies in the past when they were hit. Edit: it was probably AddForce. "I thought SetVelocity did work on character controllers". I use a controller... So i'm asking if there is a way to purge my entity from every force of last SetInput.. I await for news, thanks in advance Edited December 23, 2016 by boris47 Quote I'm not english, so please sorry for my grammatical errors I'm using Leadwerks and can programm in C++ and LUA Link to comment Share on other sites More sharing options...
Roberto14 Posted December 24, 2016 Author Share Posted December 24, 2016 OK, good news and bad ones: thanks to this post: Was SetInput changed to not trigger when move is 0? I'm trying to call it to rotate my character but it doesn't seem to unless the character is moving. This will rotate the character controller->SetInput(camerarotation.y, 0.000000000000000000001, strafe*speed, jump); but this will not controller->SetInput(camerarotation.y, 0.0, strafe*speed, jump); http://www.leadwerks.com/werkspace/topic/15442-setinput/ i figured out how to instantly stop my entity: pEntity->SetInput( 0, 0.000000000000000000001, 0.000000000000000000001, 0.000000000000000000001, false, 0.0f, 100.f ); pEntity->UpdatePhysics(); this on every physic update stop my entity if i have set gravity to false. The bad new is that in my game using set velocity has really ambiguos behaviour: if i use SetMass and then SetVelocity I do not get any effect without SetMass i get a newton engine crash I found a solution but SetVelocity doesn't work correctly in my case and this is really strange.. Quote I'm not english, so please sorry for my grammatical errors I'm using Leadwerks and can programm in C++ and LUA Link to comment Share on other sites More sharing options...
Ma-Shell Posted December 24, 2016 Share Posted December 24, 2016 You could try disabling physics for that body for one frame and then enabling it again the next frame (haven't tried, whether this will actually stop the entity but it might be worth a try). In this post I described how to do that: http://www.leadwerks.com/werkspace/topic/13883-hidden-entities-still-get-iterated-over-in-le/page__st__20#entry95890 Quote Link to comment Share on other sites More sharing options...
Roberto14 Posted December 24, 2016 Author Share Posted December 24, 2016 Mmmm, i create a pivot and use it as my player entity, how can i operate on a body of that pivot?? It has one? Quote I'm not english, so please sorry for my grammatical errors I'm using Leadwerks and can programm in C++ and LUA Link to comment Share on other sites More sharing options...
Ma-Shell Posted December 24, 2016 Share Posted December 24, 2016 Your pivot is an entity and an entity has a body. Try this: NewtonBodyDisableSimulation(((NewtonDynamicsBody*)pEntity->body)->body); Quote Link to comment Share on other sites More sharing options...
Roberto14 Posted January 3, 2017 Author Share Posted January 3, 2017 Your pivot is an entity and an entity has a body. Try this: NewtonBodyDisableSimulation(((NewtonDynamicsBody*)pEntity->body)->body); More than using that function that disable simulation, so disable also object collisions ( and i need this ), i prefer to set velocity manually, using Leadwerks::NewtonDynamicsBody *pBody = dynamic_cast< Leadwerks::NewtonDynamicsBody *>( MyPivot->body ); pBody->velocity = Vec3( 0.0 ); Now i thing this is a permanent solution for every case, just i hope.. Quote I'm not english, so please sorry for my grammatical errors I'm using Leadwerks and can programm in C++ and LUA 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.