Jump to content

Physic Stop


Roberto14
 Share

Recommended Posts

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 ( smile.png ) but i need the possibility to stop my entity in the air by pressing a key.

 

How can i achieve this?

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

Result are

 

Stop doesn't affect remaining forces

and with SetVelocity i got crash, because of some internal error:

post-16806-0-14282200-1482410296_thumb.jpg

 

Symply i jump and when player land over terrain should stop, immediately.

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

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" );

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

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 by boris47

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

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..

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

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

Link to comment
Share on other sites

  • 2 weeks later...

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..

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

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.

 Share

×
×
  • Create New...