Jump to content

How do I use TController?


cocopino
 Share

Recommended Posts

Hi,

 

I'm picking a point on my terrain and put a "goal" pivot there to move my character towards. Here's the pseudo code:

 

SuperStrict
Framework leadwerks.engine

Import "D:/Program Files/Leadwerks240/BMX/Framework/Framework.bmx"
RegisterAbstractPath("D:/Program Files/Leadwerks240")

Graphics(800, 600)

Global fw:TFramework = CreateFramework()
If Not fw RuntimeError "Failed to initialize engine."

Local scene:TEntity = LoadScene("abstract::testmap2.sbx")

Local cam:TEntity = fw.Main.camera

Local controller:TController = createcontroller(1.8, 0.5)
controller.SetMass(5.0)
controller.SetCollisionType(1)

Local mesh:TMesh = createcube(controller)
mesh.SetColor(Vec3(1, 0, 0))

controller.SetPosition(Vec3(0, 5, 0))

Local goal:Tentity = CreateCube()
goal.SetColor(Vec3(0, 0, 1))
SeedRnd(MilliSecs())
goal.SetPosition(Vec3(Rnd(-50, 50), 4, Rnd(-50, 50)))


Repeat

If KeyHit(KEY_ESCAPE) Exit
If AppTerminate() Exit

If (KeyHit(KEY_1))
	controller.Point(goal)
	UpdateController(controller, controller.rotation.y, 5.0)
ElseIf (KeyHit(KEY_2))
	goal.SetPosition(Vec3(Rnd(-50, 50), 4, Rnd(-50, 50)))
EndIf

cam.SetPosition(Vec3(controller.position.x + 8, controller.position.y + 20, controller.position.z + 8))
cam.Point(controller)

fw.Update()
fw.Render()

DrawText("Press 1 to go to destination", 5, 20)
DrawText("Press 2 to change destination", 5, 35)

Flip(0)

Forever

GCCollect()
End

 

First problem:

- the controller will take very a long time to "start up", it's building up speed like a car.

Second problem:

- when changing destination, the controller will also respond like a car, but now if it's on ice. It will continue slipping for several seconds.

 

I'm trying to use the controller like a character would walk, with slipping nor speed buildup. what changes do I need to make?

 

Thanks!

desktop: Quad core Q6600 + 4GB + ATI HD4890 + XP

laptop: Dual core T6400 + 4 GB + NVidia 9600M GT + Vista 32

Link to comment
Share on other sites

you need to look at the parameters for UpdateController. One of them is for setting the max acceleration... set it between 200-500 and you should see the sliding and slow build up go away...

 

UpdateController( controller:TController, angle:Float, move:Float, strafe:Float=0.0, jump:Float=0.0, maxacceleration:Float=0.5, iterations:Int=1, crouchmode:Int=0 )

Win7 64bit / Intel i7-2600 CPU @ 3.9 GHz / 16 GB DDR3 / NVIDIA GeForce GTX 590

LE / 3DWS / BMX / Hexagon

macklebee's channel

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