george68 Posted June 1, 2021 Share Posted June 1, 2021 Hi, In the video below you can see that every time I move the character forward, it moves a bit to the direction of the moving platform Does anyone know if I can avoid this? Here is how I create the player: pControler = Pivot::Create(); pControler->SetPhysicsMode(Entity::CharacterPhysics); pControler->SetMass(1.0); pControler->SetPosition(pEntity->GetPosition(true)); pEntity->SetParent(pControler, true); pEntity->SetPosition(0.0, getHeight(), 0.0); pEntity->SetShape(NULL); pEntity->SetMass(0.0); and here is how I create the platform: std::string szVal; Vec3 origin; Vec3 distance; origin = pEntity->GetPosition(true); distance.x = std::atof(pEntity->GetKeyValue("Dx", "").c_str()); distance.y = std::atof(pEntity->GetKeyValue("Dy", "").c_str()); distance.z = std::atof(pEntity->GetKeyValue("Dz", "").c_str()); bEnabled = (bool)std::atoi(pEntity->GetKeyValue("Enabled", "").c_str()); pEntity->SetShadowMode(2); pEntity->SetGravityMode(false); pEntity->SetCollisionType(Collision::Prop); pEntity->SetMass(1.0); pJoint = NULL; SetTarget(origin, origin + distance); The SetTarget function: Vec3 pin; mOrigin = origin; mTarget = target; mDistance = mTarget - mOrigin; if (pJoint) { pJoint->DisableMotor(); pJoint->Release(); } pin = mDistance.Normalize(); pJoint = Joint::Slider(mOrigin.x, mOrigin.y, mOrigin.z, pin.x, pin.y, pin.z, pEntity, NULL); pJoint->EnableMotor(); pJoint->SetMotorSpeed(2.0); pJoint->SetTargetAngle(mDistance.Length()); Quote Link to comment Share on other sites More sharing options...
Marcousik Posted June 1, 2021 Share Posted June 1, 2021 Really not sure but maybe you could try with resetting the friction force to 0 or just reducing the forces SetFriction(0) https://www.leadwerks.com/learn?page=API-Reference_Object_Entity_SetFriction Quote Link to comment Share on other sites More sharing options...
SpiderPig Posted June 1, 2021 Share Posted June 1, 2021 I can't see anything obvious either, but would parenting the player to the platform help? I'm not sure how that effects the physics simulation though. Quote Link to comment Share on other sites More sharing options...
george68 Posted June 1, 2021 Author Share Posted June 1, 2021 Thank you both for the tips, but none of these work. I was hoping that setting the physics mode to 'CharacterPhysics' for the player, will solve issues like these Quote Link to comment Share on other sites More sharing options...
Marcousik Posted June 1, 2021 Share Posted June 1, 2021 I can imagine that this for you annoying effect could exactly be desired in another case/game; I mean that the player controller physics reacts to a moving ground, like for example rolling stairs have to accelerate the speed of the player movement going in the same way. So it is really difficult.. Did you try to remove the gravity? SetGravityMode(false) Quote Link to comment Share on other sites More sharing options...
Josh Posted June 1, 2021 Share Posted June 1, 2021 Getting the controller to be influenced by its environment was a fairly difficult task and the ground velocity calculation is obviously a little off. 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...
george68 Posted June 1, 2021 Author Share Posted June 1, 2021 Quote I can imagine that this for you annoying effect could exactly be desired in another case/game I agree. I tried both the friction and the gravity without success. It seems that a character controller has its own rules. If I have time, I'll try to implement a player without using the character controller physics. Quote Link to comment Share on other sites More sharing options...
Josh Posted June 1, 2021 Share Posted June 1, 2021 1 minute ago, george68 said: I agree. I tried both the friction and the gravity without success. It seems that a character controller has its own rules. If I have time, I'll try to implement a player without using the character controller physics. Honestly, for now I would live with it if possible. I've seen much worse behavior in high-end games. We want to get everything 100% perfect, but in terms of what we can do in the short-term I would not worry about it for now. 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...
george68 Posted June 1, 2021 Author Share Posted June 1, 2021 1 minute ago, JMKUltra said: Honestly, for now I would live with it if possible. I've seen much worse behavior in high-end games. We want to get everything 100% perfect, but in terms of what we can do in the short-term I would not worry about it for now. It is true A month ago I was playing with the GODOT engine and I found that there is an alternative function 'update()' for the player, with a snap parameter which perfectly fits for a nice movement on moving platforms (2D) Quote Link to comment Share on other sites More sharing options...
SpiderPig Posted June 1, 2021 Share Posted June 1, 2021 If you want you could just add some invisible walls to the platform to stop you falling off. Make some code that enables or disables them depending on what you want to do. Quote Link to comment Share on other sites More sharing options...
george68 Posted June 1, 2021 Author Share Posted June 1, 2021 59 minutes ago, Lethal Raptor Games said: If you want you could just add some invisible walls to the platform to stop you falling off. Make some code that enables or disables them depending on what you want to do. Thank you. I prefer to write some code to cancel the controller on the platform and move the player as a regular rigid body. I don't know though, if this is possible. Quote Link to comment Share on other sites More sharing options...
Josh Posted June 1, 2021 Share Posted June 1, 2021 It probably depends on when you expect your game will be finished. Within six months I think we can definitely expect to see the new 3D engine, at least in an advanced beta. And the new engine is a new foundation with which I am very interested in delivering a 100% bug-free experience. So it might make sense to just keep adding to the game right now and port over to the new engine in a few months. 1 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...
george68 Posted June 1, 2021 Author Share Posted June 1, 2021 I really don't know much about the new engine, except the GUI. I don't think that the new engine will face issues like this one above., since this is the nature of a physics engine. And this is exactly the reason I prefer to avoid physics most of the time 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.