Jump to content

gamecreator

Members
  • Posts

    4,937
  • Joined

  • Last visited

Posts posted by gamecreator

  1. I'm manually checking if the character can move forward, or up a hill, or down a hill or if it bumps into a wall.

     

    groundcheck.gif

     

    Let's say I need to move the character over 10 spaces this frame. I first check if it can move over 1 space. If it can, I move it. Then I check the next space. So on. I think it would be a waste to use EntityCollisionCallback because I would have to pass it dozens of possible situations, each through an individual (so dozens) of entities, if I understand its use correctly.

     

    I'm probably doing this the hard way though.

  2. Is there a way to instantly know if two entities or two bodies are colliding without using EntityCollisionCallback? I'm trying to do something like this:

     

    //  Move entity forward 2 spaces
    PositionEntity(entity1,Vec3(2,0,0),1);
    
    //  If it collides with something
    if(EntitiesAreColliding(entity1,entity2))
    {
      //  Move entity forward 1 space
      PositionEntity(entity1,Vec3(1,0,0),1);
    
      //  If it still collides with something
      if(EntitiesAreColliding(entity1,entity2))
      {
         //  Don't move entity
         PositionEntity(entity1,Vec3(0,0,0),1);
      }
    }
    

  3. I think anyone who comes across Leadwerks already knows that they're looking for. They won't mistake Leadwerks Engine for an automobile company just as they won't mistake Leadwerks3D for a computer animation film studio.

     

    But strongly agreed that the shorter the better. The easier it is to say, the easier it is to talk about. There's a reason it's called GMail, not Google Mail.

  4. As expected, setting everything to the tutorial values made the controller move incredibly slow. I had the move speed at 2 (the run speed in the tutorial). Setting it to 3 already made the controller bump off the ramp. (I even got rid of the side backwall and frontwall entities just in case there was friction there.)

  5. Their move value is 1 while walking, 2 while running. Mine is 10. I guess one solution could be to scale down the world and player to a 10th of their size and then use smaller values. But I suspect this issue will still come up with steeper ramps.

     

    I wish Leadwerks handled this. I appreciate the help Metatron.

  6. True. Gravity doesn't pull it down fast enough. Now, since forces and positioning don't work on character controllers, what are my options? Some sort of hack with a negative jump?

     

    Imagine if the character was going even faster (something like Sonic the Hedgehog) but it still needed to stay on the ground.

     

    I'd love to get this to work as I really like that the sliding joints work with character controllers (for moving platforms and such) but I may have to code the physics and collision myself.

  7. Hello. How do you avoid the bounce of a character controller on a ramp? The problem is twofold:

     

    1. It looks bad to have a character bounce down a ramp when they should be running

    2. ControllerAirborne is usually 1 which means that if you use that to detect if you can jump, you're out of luck. Most of the time the character can't.

     

    Below is a quick video and the code:

     

     

    #include "engine.h"
    
    #pragma warning(disable:58) 
    
    int WINAPI WinMain( HINSTANCE hInstance,
    				HINSTANCE hPrevInstance,
    				LPSTR lpCmdLine,
    				int nShowCmd ) 
    {
    if(!Initialize()) return 1;
    
    RegisterAbstractPath("D:/Programming/Leadwerks Engine SDK");
    
    // Set graphics mode
    if(!Graphics(640,480))
    {
    	MessageBoxA( 0,"Failed to set graphics mode.","Error",0);
    	return 1;
    }
    
    // Create framework object and set it to a global object so other scripts can access it
    TFramework fw = CreateFramework();
    if(fw==NULL)
    {
    	MessageBoxA(0,"Failed to initialize engine.","Error",0);
    	return 1;
    }
    
    // Set Lua framework object
    SetGlobalObject("fw",fw);
    
    // Set Lua framework variable
    BP lua=GetLuaState();
    lua_pushobject(lua,fw);
    lua_setglobal(lua,"fw");
    lua_pop(lua,1);
    
    // Get framework main camera
    TCamera camera = GetLayerCamera(GetFrameworkLayer(0));
    PositionEntity(camera,Vec3(13,5,-12));
    RotateEntity(camera,Vec3(15,0,0));
    
    TLight light=CreateDirectionalLight();
    RotateEntity(light,Vec3(45,45,45));
    
    SetWorldGravity(Vec3(0,-80,0));
    
    TModel level=LoadModel("abstract::level.gmf");
    if (!level)
    {
    	MessageBoxA(0,"Error","Failed to load mesh.",0);
    	goto exitapp;	
    }
    EntityType(level,2);
    
    TController player=CreateController(1.8,0.4,0.5,45.01);
    EntityType(player,1);
    SetBodyMass(player,10);
    PositionEntity(player,Vec3(0,1,0));
    
    float move=0.0;
    float strafe=0.0;
    
    TEntity         backwall = CreateBodyBox(50,50,1,0);
    MoveEntity     (backwall, Vec3(0,0,-1));
    SetBodyMass    (backwall, 0);
    EntityType     (backwall, 2);
    
    TEntity         frontwall = CreateBodyBox(50,50,1,0);
    MoveEntity     (frontwall, Vec3(0,0,1));
    SetBodyMass    (frontwall, 0);
    EntityType     (frontwall, 2);
    
    Collisions(1,2,true);
    Collisions(1,2,true);
    
    DebugPhysics(1);
    
    SetAntialias(1);
    
    while(!KeyHit(KEY_ESCAPE))
    {
    	TVec3 pos;
    	TVec3 vel;
    
    	move=KeyDown(KEY_RIGHT)-KeyDown(KEY_LEFT);
    	pos=EntityPosition(player,1);
    	PositionEntity(camera,Vec3(pos.X,pos.Y+4,-15));
    	PositionEntity(backwall, Vec3(pos.X,pos.Y,-1));
    	PositionEntity(frontwall, Vec3(pos.X,pos.Y,1));
    
    	move*=10;
    
    	float jump=0.0;
    	if (KeyHit(KEY_S)) {
    		if (!ControllerAirborne(player)) {
    			jump=30.0;
    		}
    	}
    
    	UpdateController(player,270.0,move,0.0,jump,50);
    
    	UpdateFramework();
    	RenderFramework();
    
    	DrawText(0,20,"move: %f",move);
    	DrawText(0,40,"airborne: %d",ControllerAirborne(player));
    
    
    	Flip(0);
    }
    
    return Terminate();
    }
    

     

    I really need to guarantee that the controller stays flat on the ground whenever it's moving downhill. Thanks for any help.

  8. Hey, I just saw this thread from a separate search. paramecij, I think a lot of people would be in your debt if you made your trees and foliage (and rocks, if you have them) available. I suggest uploading them to the Asset Store. If they're decent, you could even charge something reasonable for them.

  9. PositionEntity doesn't seem to work on the character controller. I originally posted a thread here but I thought I'd post my code here as well, in case you have any ideas.

     

    Very simple code. No assets needed. Copy it right into a new project if you'd like.

     

    #include "engine.h"
    
    #pragma warning(disable:58) 
    
    int WINAPI WinMain( HINSTANCE hInstance,
    				HINSTANCE hPrevInstance,
    				LPSTR lpCmdLine,
    				int nShowCmd ) 
    {
    if(!Initialize()) return 1;
    
    RegisterAbstractPath("D:/Programming/Leadwerks Engine SDK");
    
    // Set graphics mode
    if(!Graphics(640,480))
    {
    	MessageBoxA( 0,"Failed to set graphics mode.","Error",0);
    	return 1;
    }
    
    // Create framework object and set it to a global object so other scripts can access it
    TFramework fw = CreateFramework();
    if(fw==NULL)
    {
    	MessageBoxA(0,"Failed to initialize engine.","Error",0);
    	return 1;
    }
    
    // Set Lua framework object
    SetGlobalObject("fw",fw);
    
    // Set Lua framework variable
    BP lua=GetLuaState();
    lua_pushobject(lua,fw);
    lua_setglobal(lua,"fw");
    lua_pop(lua,1);
    
    // Get framework main camera
    TCamera camera = GetLayerCamera(GetFrameworkLayer(0));
    PositionEntity(camera,Vec3(13,5,-12));
    RotateEntity(camera,Vec3(15,0,0));
    
    TLight light=CreateDirectionalLight();
    RotateEntity(light,Vec3(45,45,45));
    
    SetWorldGravity(Vec3(0,-80,0));
    
    // PLAYER
    TController player=CreateController(1.8,0.4,0.5,45.01);
    EntityType(player,1);
    SetBodyMass(player,10);
    PositionEntity(player,Vec3(0,1,0));
    
    float move=0.0;
    float strafe=0.0;
    
    // GROUND
    TEntity ground=CreateBodyBox(40,1,1,0);
    SetBodyMass(ground,0);
    EntityType(ground,2);
    
    Collisions(1,2,true);
    
    DebugPhysics(1);
    
    SetStats(2);
    
    while(!KeyHit(KEY_ESCAPE))
    {
    	TVec3 pos;
    
    	move=KeyDown(KEY_RIGHT)-KeyDown(KEY_LEFT);
    	pos=EntityPosition(player,1);
    	PositionEntity(camera,Vec3(pos.X,pos.Y+4,-15));
    
    	float jump=0.0;
    	if (KeyHit(KEY_SPACE)) {
    		if (!ControllerAirborne(player)) {
    			jump=30.0;
    		}
    	}
    
    	move*=10;
    
    	UpdateController(player,270.0,move,0.0,jump,50);
    
    	pos=EntityPosition(player,1);
    //		PositionEntity(player,Vec3(pos.X,pos.Y,0),1);
    
    	UpdateFramework();
    	RenderFramework();
    
    	DrawText(0,300,"player.Z: %f",pos.Z);
    
    	Flip(0);
    }
    
    return Terminate();
    }
    

    With the PositionEntity line commented, the character controller works fine. With it uncommented, it seems to break (the character controller becomes almost entirely non-responsive). But please let me know if I'm doing something wrong.

  10. Thanks YouGroove. I'm definitely not out of workaround options. Worst case scenario, if the walls around the player don't end up working out, I may simply remove the physics altogether and do them myself, using another library called PMask. It's much more of a pain but it also gives me full control.

     

    But yes, this really should be in the engine, in my opinion.

  11. I've come to the understanding that LE2 doesn't support body forces for character controllers. It would be really nice if LE3 supported this (even better if 2 did also!). It's useful for any type of game.

     

    Also, I'm making a platformer a little bit like Trine. It would be nice to limit body and character controller movement to a 2D plane with a single function, like

     

    RestrainBodyMovement(player1,Vec3(1,1,0));

    Thanks!

     

     

    Bonus points if

     

    RestrainBodyMovement(player1,Vec3(.5,2,0));

    makes movement half speed on the X axis, double speed on the Y axis and 0 on the Z axis. :rolleyes:

  12. Thanks guys. Aily, I've thought of doing what you mention and wasn't sure if it was necessary but it seems it is. Rick, surprisingly, I'm only having the controller go strictly left and right and the plane it's on is level. Even if it goes up and down it doesn't tilt forward or back, if that makes sense. And yet, I've had the controller fall off the edge on the back somehow. Not a problem. I'll just implement Ailly's method. Was just wondering if what I suspected was the case. Thanks again.

×
×
  • Create New...