Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Dark Physics & Dark A.I. & Dark Dynamix / Reed's Alternate Character Controller

Author
Message
AmbulanceGames
9
Years of Service
User Offline
Joined: 15th May 2010
Location: Salt Lake City, UT
Posted: 10th Jan 2012 02:28
Hey, I found this on the Techniques sticky here and tried it out, only where the update function says it ensures the character won't fall over, turns out it doesn't work. Just wondering if anyone knew why or if they've got it working. I'm trying to use this with a large terrain I've made in 3DWS so I don't know if maybe the collision on that is funky but here's what I copied

[/code]
`Character controller functions
Function Phy_SetupCharacterControllers(MaterialNum)
`Make the material, so it has no bounce
Global CharacterControllerMaterial:CharacterControllerMaterial = MaterialNum
phy Make material CharacterControllerMaterial, "ccmat"
Phy set material restitution CharacterControllerMaterial, 0.0
Phy build material CharacterControllerMaterial
EndFunction

Function Phy_MakeCharacterController(ControllerID, Sizex as float, Sizey as float, Sizez as float)
`First make a rigid body box for the controller
Make object box ControllerID, Sizex, Sizey, Sizez
`Phy make rigid body dynamic box
Phy make rigid body dynamic box ControllerID, CharacterControllerMaterial
EndFunction

Function Phy_MoveCharacterController(ControllerID, Speed as float)
`Move the object forward (along the z axis)
phy add rigid body local force ControllerID, 0, 0, Speed, 4
EndFunction

Function Phy_RotateCharacterController(ControllerID, YAngle as float)
`Rotate the controller along its y axis
Phy set rigid body rotation ControllerID, 0, YAngle, 0
EndFunction

Function Phy_MoveCharacterControllerLeft(ControllerID, Speed as float)
`Apply a negitive force along the x axis
phy add rigid body local force ControllerID, -Speed, 0, 0, 4
EndFunction

Function Phy_MoveCharacterControllerRight(ControllerID, Speed as float)
`Apply a positive force along the x axis
phy add rigid body local force ControllerID, Speed, 0, 0, 4
EndFunction

Function Phy_UpdateCharacterController(ControllerID)
`Make sure the object does not fall over
phy set rigid body rotation ControllerID, 0, Object angle y(ControllerID), 0
`phy set rigid body linear damping ControllerId, 100
`Stop the momentum
phy set rigid body linear momentum ControllerID, 0.0, Phy get rigid body linear momentum y(ControllerID) , 0.0
`phy add rigid body local force ControllerID, 0, -1, 0, 4
EndFunction


Here's my sloppy code I'm trying to get it to work with.


phy start
sync on : sync rate 60
set window on : set display mode 1200,800,32
set ambient light 100 : center window
autocam off

//main vars
gameOn = 1
playerY = 4500
jump = 0
global ControllerID = 400
global Sizex as float = 50.0
global Sizey as float = 160.0
global Sizez as float = 50.0
global Speed = 15

//objects
load object "testum/Ground.dbo",030 : phy make rigid body static mesh 030
load object "testum/Grass1.dbo",300
position object 300,-700,-2448,96 : scale object 300,100,100,100
set object transparency 300,2
load object "testum/Clover1.x",301 : scale object 301,100,100,100
position object 301,-5056,-2444,0 : set object transparency 301,2
load object "testum/mm.x",302
position object 302,0,0,0 : scale object 302,1000,1000,1000 : set object texture 302,2,3
Phy_SetupCharacterControllers(MaterialNum)
Phy_MakeCharacterController(ControllerID,Sizex,Sizey,Sizez)
phy set rigid body position ControllerID,0,-2200,-300
set object wireframe ControllerID,1
phy set gravity 0.0,-3.0,0.0

//camera
make camera 001 : position camera 001,0,-2300,0
set camera range 001,0.5,500000


//loop
while gameOn = 1
text 10,10,"FPS: "+str$(Screen FPS())
//position camera cam1,object position x(031),object position y(031)+150,object position z(031)
//spinning sky and cam control
yrotate object 302,OBJECT ANGLE Y(302) + 0.005
if keystate(17) = 1
Phy_MoveCharacterController(ControllerID,Speed)
endif
control camera using arrowkeys 001,3,3

Phy_UpdateCharacterController(ControllerID)
phy update
sync
endwhile

`Character controller functions
Function Phy_SetupCharacterControllers(MaterialNum)
`Make the material, so it has no bounce
Global CharacterControllerMaterial:CharacterControllerMaterial = MaterialNum
phy Make material CharacterControllerMaterial, "ccmat"
Phy set material restitution CharacterControllerMaterial, 0.0
Phy build material CharacterControllerMaterial
EndFunction

Function Phy_MakeCharacterController(ControllerID, Sizex as float, Sizey as float, Sizez as float)
`First make a rigid body box for the controller
Make object box ControllerID, Sizex, Sizey, Sizez
`Phy make rigid body dynamic box
Phy make rigid body dynamic box ControllerID, CharacterControllerMaterial
EndFunction

Function Phy_MoveCharacterController(ControllerID, Speed as float)
`Move the object forward (along the z axis)
phy add rigid body local force ControllerID, 0, 0, Speed, 4
EndFunction

Function Phy_RotateCharacterController(ControllerID, YAngle as float)
`Rotate the controller along its y axis
Phy set rigid body rotation ControllerID, 0, YAngle, 0
EndFunction

Function Phy_MoveCharacterControllerLeft(ControllerID, Speed as float)
`Apply a negitive force along the x axis
phy add rigid body local force ControllerID, -Speed, 0, 0, 4
EndFunction

Function Phy_MoveCharacterControllerRight(ControllerID, Speed as float)
`Apply a positive force along the x axis
phy add rigid body local force ControllerID, Speed, 0, 0, 4
EndFunction

Function Phy_UpdateCharacterController(ControllerID)
`Make sure the object does not fall over
phy set rigid body rotation ControllerID, 0, Object angle y(ControllerID), 0
`phy set rigid body linear damping ControllerId, 100
`Stop the momentum
phy set rigid body linear momentum ControllerID, 0.0, Phy get rigid body linear momentum y(ControllerID) , 0.0
`phy add rigid body local force ControllerID, 0, -1, 0, 4
EndFunction
[code]

if anyone's got any suggestions, I'd appreciate it.
AmbulanceGames
9
Years of Service
User Offline
Joined: 15th May 2010
Location: Salt Lake City, UT
Posted: 10th Jan 2012 02:29
and it looks like I screwed up the whole collapsible code thing on here too...
MrValentine
AGK Backer
8
Years of Service
User Offline
Joined: 5th Dec 2010
Playing: FFVII
Posted: 10th Jan 2012 07:13
Interesting... I am about a week away from playing with 3DWS and DP and DAI soon so will keep this one in view... I had this idea too once... sort of sinilar making the object a type of object but my logic of it creating a rebound square made me drop the idea... but you made this in response to use instead of static mesh right?

Guh my head hurts... sorry if I did not make sense...

Login to post a reply

Server time is: 2019-10-16 20:27:25
Your offset time is: 2019-10-16 20:27:25