Jump to content

Platform issue


george68
 Share

Recommended Posts

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

 

Link to comment
Share on other sites

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)

 

 

Link to comment
Share on other sites

Getting the controller to be influenced by its environment was a fairly difficult task and the ground velocity calculation is obviously a little off.

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

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.

Link to comment
Share on other sites

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.

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

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)

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

  • Upvote 1

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

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

 

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