Jump to content

Controller issue AGAIN


Raul
 Share

Recommended Posts

After doing the wiki tutorial and read one more time the article from Resources I thought I managed the Controller. But there are some problems:

 

I made a little scene in the Editor. Testing with the fpsshooter script is ok. The character is correctly moving and sliding. The coll detection works fine with all the object.

In my game the controller is jumping back when hitting a wall/fence and sometimes is going through them.

 

This is my code:

 

Create Player:

	
PlayerController=CreateController(1.8,0.45,0.25,46);
EntityType(PlayerController,1);
SetBodyMass(PlayerController,10);

 

Update Player:

 

mx=Curve(MouseX()-GraphicsWidth()/2,mx,6);
my=Curve(MouseY()-GraphicsHeight()/2,my,6);
MoveMouse(GraphicsWidth()/2,GraphicsHeight()/2);
PlayerRotation.X=PlayerRotation.X + my/10.0;
PlayerRotation.Y=PlayerRotation.Y - mx/10.0;

PlayerMove=KeyDown(KEY_W)-KeyDown(KEY_S);
PlayerStrafe=KeyDown(KEY_D)-KeyDown(KEY_A);

if (KeyDown(KEY_LSHIFT)||KeyDown(KEY_RSHIFT)) {
	if (!ControllerAirborne(PlayerController)) {
		PlayerMove*=2.0;
		PlayerStrafe*=2.0;
	}
}

float PlayerJump=0.0;
if (KeyHit(KEY_SPACE)) {
	if (!ControllerAirborne(PlayerController)) {
		PlayerJump=6.0;
	}
}

//Set controller input
UpdateController(PlayerController,PlayerRotation.Y,PlayerMove*3,PlayerStrafe*3,PlayerJump,50);

PlayerPosition=EntityPosition(PlayerController);
PlayerHeadPosition=PlayerPosition;

PlayerHeadPosition.Y = Curve(PlayerPosition.Y+1.8,PlayerHeadPosition.Y,4);
PlayerHeadPosition=Vec3(PlayerPosition.X,PlayerHeadPosition.Y,PlayerPosition.Z);

 

I alos tried the technique from the script (calculating the Strafe and Move using the Curve) but in that case the controller cannot be controlled. It simply goes trough objects

 

Also I noticed a thing. My controller has 1.8 height.

 

If set the PlayerHeadPosition.Y = PlayerPosition + 1.8, when in debug mode I saw the head (also the camera) is in the middle of the controller..

i5 2.7Ghz, GTS 450, 8GB Ram, Win7 x64; Win8 x64

rvlgames.com - my games

RVL Games Facebook Page, YouTube Channel

 

Blitzmax :)

Link to comment
Share on other sites

Rick: I removed the Curve and now its ok. Where is the problem in this case? I still want to use this function (Curve)

 

Rick + Lumooja: The fence is taken from the Assets gallery. But the problem is that I have that "jumping back" also when hitting a wall which is not 0 mm :) Its true is not as bad as fence back but is still there.

 

But why playing the editor is working fine and smooth and in my game sucks?

 

p.s:

 

The physic bodys are not 0 mm.

i5 2.7Ghz, GTS 450, 8GB Ram, Win7 x64; Win8 x64

rvlgames.com - my games

RVL Games Facebook Page, YouTube Channel

 

Blitzmax :)

Link to comment
Share on other sites

When you walk, your head bobs up and down using a curve (with a steeper curve when your leg hits the ground). Even in LCP1 we have that. I tried also swaying around the Z axis, but I got seasick, so I disabled it. And you don't rotate around the Z axis much at all when walking or running.

 

The code is very simple, but it adds a great realism to any game (also 3 different footstep sounds):

double walkadd=AppSpeed()*Length(GetBodyVelocity(game.scene.GetCurrentPlayer()->body));
walktimer+=walkadd;
game.scene.GetCurrentPlayer()->eyeoffset.Y=Curve(1.0-0.4*sin(walktimer/500.0),game.scene.GetCurrentPlayer()->eyeoffset.Y,16);
if(walktimer>125)
{
walktimer-=125;
string i="";
i=49+(int)random(0,3);
EmitSound(game.scene.GetCurrentPlayer()->body,LoadSound((str)string("abstract::walk"+i+".ogg").c_str()));
}

Ryzen 9 RX 6800M ■ 16GB XF8 Windows 11 ■
Ultra ■ LE 2.53DWS 5.6  Reaper ■ C/C++ C# ■ Fortran 2008 ■ Story ■
■ Homepage: https://canardia.com ■

Link to comment
Share on other sites

It's pretty nice and doesn't make you sick when it's done right, and not unnaturally. And if someone still gets sick from it, then he's obviously not a good player as he can't stand some battle rumble :) So the advantage goes to the players who can stand more.

 

It's the same with other game aspects too, I plan to make a game which is so scary that you can't play if you're too scared to play it :) It should have also 3D sounds, so you can't play it if you don't use headphones or have a decent 8.0 surround system.

 

Games need a challenge to be fun, and lots of different challenges. I'm just playing C&C 95, and it's also damn challenging because the enemies zerg your base all the time, but that's what makes it fun.

Ryzen 9 RX 6800M ■ 16GB XF8 Windows 11 ■
Ultra ■ LE 2.53DWS 5.6  Reaper ■ C/C++ C# ■ Fortran 2008 ■ Story ■
■ Homepage: https://canardia.com ■

Link to comment
Share on other sites

@Lumooja: your code is working (at least is an alternative to my simple Curve utilization) BUT no head bobs effect is present. I dont really want this effect but I am just afraid I am doing something wrong.

 

Also another strange thing happen. I have a crate (an ammo box). If I set its collision to "Prop" when I go near it, it simply throw me away through walls for a long distance :)

i5 2.7Ghz, GTS 450, 8GB Ram, Win7 x64; Win8 x64

rvlgames.com - my games

RVL Games Facebook Page, YouTube Channel

 

Blitzmax :)

Link to comment
Share on other sites

You should see this... I changed the box mass to 5 from 10. Now when I hit it, sometimes is throwing me away, sometimes the box is jumping and flow in the air :| until I hit again.

 

I have the gravitation set to 0, -20 , 0

 

p.s.

The player has the mass 80

i5 2.7Ghz, GTS 450, 8GB Ram, Win7 x64; Win8 x64

rvlgames.com - my games

RVL Games Facebook Page, YouTube Channel

 

Blitzmax :)

Link to comment
Share on other sites

I had this problem but found that it was because I had not updated the files in my project folder when i did the last update.

Worked perfectly after I did so. Maybe not your problem, I don't know.

amd quad core 4 ghz / geforce 660 ti 2gb / win 10

Blender,gimp,silo2,ac3d,,audacity,Hexagon / using c++

Link to comment
Share on other sites

My problem was that the objects hit by the controller fell toward the controller and when pushing against crates they flew behind the controller rather than in the direction pushed. Sometimes the controller would pass thru the level walls and fall out of the game. But as I said updating le solved the problem

Actualy I was using the wrong updater at first, and not the latest one.

amd quad core 4 ghz / geforce 660 ti 2gb / win 10

Blender,gimp,silo2,ac3d,,audacity,Hexagon / using c++

Link to comment
Share on other sites

I have uploaded 2 little movies about my problem.

 

Also this is a simplified version of my code:

 

PLEASE I really want to know where is the problem. I simply cannot make anything with this issues :)(

 

#include "engine.h"

void InitLeadwerks()
{
Initialize();
SetAppTitle("Game");
Graphics(1024,768,0,0,GRAPHICS_BACKBUFFER+GRAPHICS_DEPTHBUFFER);

RegisterAbstractPath("data");

SetTextureQuality(1);
TFilter(1);
AFilter(MaxAFilter());
}

int main(int argc, char** argv)
{
InitLeadwerks();
CreateWorld();

//The Framework
TFramework framework=CreateFramework();

TLayer myLayer = GetFrameworkLayer(0);
   TCamera frameworkCam=GetLayerCamera(myLayer);

   //Set Lua variable
   BP L=GetLuaState();
   lua_pushobject(L,framework);
   lua_setglobal(L,"fw");
   lua_pop(L,1);

TController player=CreateController(1.8,0.4,0.5,45.01);
EntityType(player,1);
SetBodyMass(player,10);
PositionEntity(player,Vec3(0,10,10));
DebugPhysics(1);

   // Setup map/scene
   LoadScene("abstract::map1.sbx");
Collisions(1, 1, 1);
   Collisions(1, 2, 1);

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


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

float move=0.0;
float strafe=0.0;

//Main loop
while(!KeyHit(KEY_ESCAPE)) {

move=KeyDown(KEY_W)-KeyDown(KEY_S);
strafe=KeyDown(KEY_D)-KeyDown(KEY_A);
UpdateController(player,0.0,move*3,strafe*3,0,40);
	//RotateEntity(frameworkCam,myPlayer.PlayerRotation);
	PositionEntity(frameworkCam,Vec3(0,5,0));

       UpdateAppTime();
       UpdateWorld(AppSpeed()) ; 

	//PositionEntity(frameworkCam,myPlayer.PlayerHeadPosition);

       UpdateFramework();
       RenderFramework();


	Flip(0);

}

//Stop the engine and free the dll from memory
Terminate();
return 0;
}

 

In the videos you can see how the objects are simply jumping around like crazy. This happens sometimes to my controller too. I tried all kind of mass settings. No result.

i5 2.7Ghz, GTS 450, 8GB Ram, Win7 x64; Win8 x64

rvlgames.com - my games

RVL Games Facebook Page, YouTube Channel

 

Blitzmax :)

Link to comment
Share on other sites

These lines are not needed and may cause wierd physics behavior:

        UpdateAppTime();
       UpdateWorld(AppSpeed()) ; 

UpdateFramework does those commands already.

Ryzen 9 RX 6800M ■ 16GB XF8 Windows 11 ■
Ultra ■ LE 2.53DWS 5.6  Reaper ■ C/C++ C# ■ Fortran 2008 ■ Story ■
■ Homepage: https://canardia.com ■

Link to comment
Share on other sites

The only time I have experienced a controller being "thrown" with great force was when the physics geometry had some one-sided surfaces it was moving into from behind.

 

If you want help, please post an example we can run that demonstrates your problem. Otherwise we are just speculating about what it might be.

My job is to make tools you love, with the features you want, and performance you can't live without.

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