Object movement against angular platform

Topics: Developer Forum
Jun 28, 2008 at 5:33 PM
I have two objects, my player object (which uses a circle body/geom) and a platform (which is a rectangular body/geom). If the platform is rotated, I cannot move the player object across the surface of the platform without it stopping.

Here is my player code:
this.Body = BodyFactory.Instance.CreateCircleBody(physSimulator, this.Height / 2.0f, this.Mass);
this.Position = startPosition;
this.Body.LinearDragCoefficient = 0.3f;
this.Body.MomentOfInertia = float.PositiveInfinity;
this.IsStatic = false;

this.Geometry = GeomFactory.Instance.CreateCircleGeom(physSimulator, this.Body, this.Height / 2.0f, 9);
this.Tag = "player" + _playerIndex.ToString();
this.Geometry.Tag = this.Tag;
this.Geometry.RestitutionCoefficient = 0.0f;
this.Geometry.FrictionCoefficient = 0.4f;

Platform code:
this.Body = BodyFactory.Instance.CreateRectangleBody(physSimulator, this.Width, this.Height, this.Mass);
this.Body.Rotation = 0.5f;
this.Body.IsStatic = true;
this.Body.MomentOfInertia = float.PositiveInfinity;
this.Geometry = GeomFactory.Instance.CreateRectangleGeom(physSimulator, this.Body, this.Width, this.Height);
this.Geometry.RestitutionCoefficient = 0.0f
this.Geometry.FrictionCoefficient = 1.0f;

Player movement is handled by just applying horizontal forces in the positive or negative x direction.
Any insight on what I'm missing?

Jul 4, 2008 at 5:35 PM
Does anyone have any idea? Perhaps I didn't explain the problem well enough. Need more details or code?

Currently, the body/geom for the object is just stuck against the platform and can't move across it when I apply a horizontal force. I even tried applying a small upward vertical force to help, but it didn't make any difference. Any ideas?

I appreciate any help in advance.
Jul 4, 2008 at 10:45 PM
Apparently, People have stopped using Farseer and not many people are here to help... Ill see if i can try to recreate what youve done in BlitzMax to try and figure out the problem myself...
Jul 5, 2008 at 1:00 PM
Well, My attempts seem to be working fine? Maybe the force isnt high enough... What are you using atm?
Jul 6, 2008 at 1:06 AM
My horizontal force is 3000.0f. My max horizontal speed is something like 300.0f. I basically wanted the object to reach max speed as quickly as possible, but limit it.

Perhaps you could post a code example (physics values) and compare it to see whether those values will work on my end.

Jul 6, 2008 at 12:35 PM
Edited Jul 6, 2008 at 12:45 PM
Hmmm... the code doesnt seem to paste so ill have to do it a different way

Import "source/Engine.bmx"

Graphics 1200, 900
SetClsColor(30, 60, 90)

Global Physics:TPhysicsSimulator = TPhysicsSimulator.Create(Vector2.Create(0, 100))
Global View:TPhysicsSimulatorView = TPhysicsSimulatorView.Create(Physics)
Physics.EnableDiagnostics = True

Global Player:TBody = TBodyFactory.CreateCircleBody(Physics, 30, 1)
Global PlayerG:TGeom = TGeomFactory.CreateCircleGeom(Physics, Player, 30, 20)
Position(Player, 600, 450)
Friction(PlayerG, 0.4)
LinearDrag(Player, 0.4)

Global Floor1:TBody = TBodyFactory.CreateRectangleBody(Physics, 1200, 50, 1)
Global Floor1G:TGeom = TGeomFactory.CreateRectangleGeom(Physics, Floor1, 1200, 50)
Position(Floor1, 600, 850)

Global Floor2:TBody = TBodyFactory.CreateRectangleBody(Physics, 1200, 50, 1)
Global Floor2G:TGeom = TGeomFactory.CreateRectangleGeom(Physics, Floor2, 1200, 50)
Position(Floor2, 600, 850)

Until KeyDown(Key_Escape)

Function Update()
End Function

Function Draw()
End Function

Function HandleInput()
 Speed:Float = 3000
 Force:Vector2 = Vector2.Zero()
 If KeyDown(Key_Up)
  Force.Y = -Speed
 End If
 If KeyDown(Key_Down)
  Force.Y = +Speed
 End If
 If KeyDown(Key_Left)
  Force.X = -Speed
 End If
 If KeyDown(Key_Right)
  Force.X = +Speed
 End If
 If Force.X > 300
  Force.X = 300
 End If
 If Force.X < -300
  Force.X = -300
 End If
End Function

Had to put it through Notepad firt so that it wouldnt come out with weird yellow and white lettering