Jump to content

How to change character controller height


DigitalHax
 Share

Recommended Posts

Hello. I am looking at the character controller function with the leadwerks engine, and I got it all set up, but the camera height was too low. Which brings me to another point. How come in the tutorial for character controllers, it uses a map, scene.gmf, which does not come in the zip! Can someone help me with this? I am a bit of a noob to C++. Thanks in advance.

Win7 64bit, Leadwerks SDK 2.5, Visual Studio 2012, 3DWS, 3ds Max, Photoshop CS5.

 

 

 

Life is too short to remove USB safely.

Link to comment
Share on other sites

If memory serves (which it does now and then) somewhere in the murky past the controllers origin was changed from the centre to the base of the controller .. I thnk the position the cam is moved to in that tutorial is a y value multiplied by 0.5 ... try removing the 0.5

AMD Bulldozer FX-4 Quad Core 4100 Black Edition

2 x 4GB DDR3 1333Mhz Memory

Gigabyte GeForce GTX 550 Ti OC 1024MB GDDR5

Windows 7 Home 64 bit

 

BlitzMax 1.50 • Lua 5.1 MaxGUI 1.41 • UU3D Pro • MessiahStudio Pro • Silo Pro

3D Coat • ShaderMap Pro • Hexagon 2 • Photoshop, Gimp & Paint.NET

 

LE 2.5/3.4 • Skyline UE4 • CE3 SDK • Unity 5 • Esenthel Engine 2.0

 

Marleys Ghost's YouTube Channel Marleys Ghost's Blog

 

"I used to be alive like you .... then I took an arrow to the head"

Link to comment
Share on other sites

This works to load it, but the scene doesn't collide with the player. I set the entity type and set the collisions, but it still doesn't collide with the player.

Win7 64bit, Leadwerks SDK 2.5, Visual Studio 2012, 3DWS, 3ds Max, Photoshop CS5.

 

 

 

Life is too short to remove USB safely.

Link to comment
Share on other sites

Well i created the character controller originally just following the tutorial, it worked fine and had mass and collisions,but it loaded a model instead of a map, so when i loaded a map instead, the map would be there, then you would just fall through it. even if you set it to spawn on top of it, it would still not collide with you in any way.

Win7 64bit, Leadwerks SDK 2.5, Visual Studio 2012, 3DWS, 3ds Max, Photoshop CS5.

 

 

 

Life is too short to remove USB safely.

Link to comment
Share on other sites

This is my code so far.

 

#include "engine.h"

 

int WINAPI WinMain( HINSTANCE hInstance,

HINSTANCE hPrevInstance,

LPSTR lpCmdLine,

int nShowCmd )

{

Initialize() ;

RegisterAbstractPath("F:/Leadwerks Engine SDK/Leadwerks Engine SDK");

SetAppTitle( "MyGame-Debug" );

 

//Create a graphics context

Graphics(1280,720);

 

//Create a world

if (!CreateWorld()) {

MessageBoxA(0,"Error","Failed to create world.",0);

goto exitapp;

}

 

//Create a camera

TEntity cam=CreateCamera();

CameraClearColor(cam,Vec4(0,0,1,1));

PositionEntity(cam,Vec3(0,2,-10));

 

Collisions(1,2,true);

 

//Load a model

TEntity scene=LoadScene("abstract::tunnels.sbx");

PositionEntity(scene,Vec3(3.8,-2.5,0));

if (scene==0) {

MessageBoxA(0,"Error","Failed to load model.",0);

goto exitapp;

}

EntityType(scene,2);

 

//Create a light

TLight light=CreatePointLight();

PositionEntity(light,Vec3(0,5,0));

 

//Create a render buffer

TBuffer buffer=CreateBuffer(1280,720,BUFFER_COLOR|BUFFER_DEPTH|BUFFER_NORMAL);

 

TController player=CreateController(1.8,0.4,0.5,45.01);

EntityType(player,1);

SetBodyDamping(player,0.0);

SetWorldGravity(Vec3(0,-20,0));

SetBodyMass(player,1);

PositionEntity(player,Vec3(0,1,0));

 

float move=0.0;

float strafe=0.0;

TVec3 camrotation=Vec3(0);

float mx=0;

float my=0;

 

HideMouse();

MoveMouse(GraphicsWidth()/2,GraphicsHeight()/2);

 

//Main loop

while(!KeyHit(KEY_ESCAPE)) {

 

//Camera looking

mx=Curve(MouseX()-GraphicsWidth()/2,mx,6);

my=Curve(MouseY()-GraphicsHeight()/2,my,6);

MoveMouse(GraphicsWidth()/2,GraphicsHeight()/2);

camrotation.X=camrotation.X+my/10.0;

camrotation.Y=camrotation.Y-mx/10.0;

RotateEntity(cam,camrotation);

 

//Player movement

move=(KeyDown(KEY_W)-KeyDown(KEY_S))*2.0;

strafe=(KeyDown(KEY_D)-KeyDown(KEY_A))*2.0;

 

//Jumping

float jump=0.0;

if (KeyHit(KEY_SPACE)) {

if (!ControllerAirborne(player)) {

jump=4.0;

}

}

 

//Run

if (KeyDown(KEY_LSHIFT)||KeyDown(KEY_RSHIFT)) {

if (!ControllerAirborne(player)) {

move*=2.0;

strafe*=2.0;

}

}

 

//Set controller input

UpdateController(player,camrotation.Y,move,strafe,jump,40);

 

//Update the world

UpdateWorld();

 

//Position the camera

TVec3 playerpos=EntityPosition(player);

TVec3 camerapos=EntityPosition(cam);

camerapos.Y=Curve(playerpos.Y+1.75*0.5,camerapos.Y,2.0);

camerapos=Vec3(playerpos.X,camerapos.Y,playerpos.Z);

PositionEntity(cam,camerapos);

 

//Render the scene

SetBuffer(buffer);

RenderWorld();

 

//Render lighting

SetBuffer(BackBuffer());

RenderLights(buffer);

 

//Swap the front and back buffer

Flip();

}

 

exitapp:

return Terminate();

Win7 64bit, Leadwerks SDK 2.5, Visual Studio 2012, 3DWS, 3ds Max, Photoshop CS5.

 

 

 

Life is too short to remove USB safely.

Link to comment
Share on other sites

Another thing, is that when i load the map, it always says, "could not load scripts/classes". I looked in the directory and in the folder is a fpscontroller.lua

Win7 64bit, Leadwerks SDK 2.5, Visual Studio 2012, 3DWS, 3ds Max, Photoshop CS5.

 

 

 

Life is too short to remove USB safely.

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