Player physics

BlitzMax Forums/MiniB3D Module/Player physics

Ferret(Posted 2009) [#1]
Hi,

I have a problem with newton physics from the extended version.
I can move the player, a cube of scale 10, forward and backwards using this command,

ApplyImpulse(Physic,LocalPlayer.ent,0,5,0,0,0,zacc/10)


How do i move the player left or right?
Everything i tryed rotates the player, how do i find the right spot to aply force to?


Ferret(Posted 2009) [#2]
I think i need to aply force from world coordinates, now i got this,

Local V:TVector = PhxObjGetPosition:TVector(LocalPlayer.nent)
	'Print V.X
	'Print V.Y
	'Print V.Z
		
	ApplyImpulse(Physic,LocalPlayer.ent,V.X,V.Y,V.Z,0,0,zacc/10)
	ApplyImpulse(Physic,LocalPlayer.ent,V.X,V.Y,V.Z,xacc/10,0,0)


Now if i move forward, left, forward the left/right rotates the player again???


Ferret(Posted 2009) [#3]
Woohoo, i finally got it to work.
For some reason i need to invert the z axis, don't know why but it works.

Local V:TVector = PhxObjGetPosition:TVector(LocalPlayer.nent)		
	ApplyImpulse(Physic,LocalPlayer.ent,V.X,V.Y,V.Z,0,0,zacc/10)
	ApplyImpulse(Physic,LocalPlayer.ent,V.X,V.Y,-V.Z,xacc/10,0,0)



Ferret(Posted 2009) [#4]
New problem :(

PhxObjSetRotation(LocalPlayer.nent,0 ,45 ,0 )


This seems to do nothing.


Ferret(Posted 2009) [#5]
Klepto2 confirmed the command is not working.
Now i'm completly stuck, i need a way to rotate the player.

I have an idea but don't know where to start with the math.
If i can calculate how much force to aply on x/z according to the players rotation i can move the player in the right direction.

For example, the player is rotated 45 degrees i need to aply the same amount of force on x and z axis to move in that direction.

How do i do something like this?
Is there a name for this so i can search?


Ferret(Posted 2009) [#6]
Nevermind, i give up.
In mi opinion the extended version is unusable for a game, to much broken.

I wrote mi player physics within an hour using minib3d commands only.