Player controller problem

A place to discuss everything related to Newton Dynamics.

Moderators: Sascha Willems, walaber

Player controller problem

Postby collerblade » Wed Sep 01, 2010 6:41 pm

Hi all

I have a customplayercontroller joint in my app. It works fine, but i cant detect, when a player is in airborne. How can i do that? Raycast? I think my playercontroller object allready did that, because i cant walk in the air (zero air control).
And secondly: When im on the ground, why NewtonBodyAddForce didn't works?? Now i can jump only when im in airborne. Thats interesting, but it isn't what i want :D.

Im using the version 2.24 of course.

Plz help me.
collerblade
 
Posts: 88
Joined: Mon Apr 05, 2010 12:09 pm

Re: Player controller problem

Postby collerblade » Thu Sep 02, 2010 4:18 am

Someone ?
collerblade
 
Posts: 88
Joined: Mon Apr 05, 2010 12:09 pm

Re: Player controller problem

Postby ledahut » Thu Sep 02, 2010 4:57 am

What do you mean by
is in airborne
?
This is like when you jump in first person shooter?
ledahut
 
Posts: 98
Joined: Mon Jun 21, 2010 8:03 am
Location: France

Re: Player controller problem

Postby collerblade » Thu Sep 02, 2010 6:24 am

Yes. Of course. Or if u falls down from a heigher position.

I think there is tree separated player state in newton customplayercontroller. Wher u are on the ground, when u are on a ramp and when u are in the air.
The question is, how can i query the current state???

Plz someone.
collerblade
 
Posts: 88
Joined: Mon Apr 05, 2010 12:09 pm

Re: Player controller problem

Postby collerblade » Fri Sep 03, 2010 4:46 am

Anyone ? Is my problem so specific?
collerblade
 
Posts: 88
Joined: Mon Apr 05, 2010 12:09 pm

Re: Player controller problem

Postby ledahut » Fri Sep 03, 2010 7:57 am

I never use this custom joint.

I think you can use the function NewtonBodyGetForce at start of your NewtonApplyForceAndTorque callback to know if the body is in air.
For exemple if you have gravity [0,-9.81*MASS,0].
NewtonBodyGetForce return [0,0,0] if the body is on the ground.
NewtonBodyGetForce return [0,-9.81*MASS,0] if the body is on the air. //if you didnt apply another force before, like [0,100,0] for jumping.

If you are on a ramp, I don't know but logically NewtonBodyGetForce return value bigger than 0 for x or z, and value between (-9.81*mass , 0) for y.
ledahut
 
Posts: 98
Joined: Mon Jun 21, 2010 8:03 am
Location: France

Re: Player controller problem

Postby collerblade » Sat Sep 04, 2010 3:18 pm

Good evening

Im going to try it now. But i think may speed detection is a better way. The true way is to do a raycast, and detect if something is there. But my joint do it once per update. I know that, because the player behavior is different in air. For example i cant control the player in air. But if i want to jump i have to know if am i on the ground. I can do raycast detection, but i think that is waste of time.

My second problem is:
if i want to jump & use NewtonBodyAddForce to add a force for jump. But NOTHING is happens if tha player is on the ground. In the air it works fine.
What is going on?
collerblade
 
Posts: 88
Joined: Mon Apr 05, 2010 12:09 pm

Re: Player controller problem

Postby collerblade » Sun Sep 05, 2010 5:56 am

Hi all

So. Queriing force is not a solution. When u are on the ground, gravity still has effect on u. So the force is allways at least 9.81*mass.
I tried velocity too. That seems to be a better solution, but not a perfect one.
First there is a bug sometimes, when u are moving from a ramp to another, velocity remain a pozitive value (i dont understand why), but u are standing on the ground. Because of this, sometimes u cant jump when u are on the ground.
The second problem with speed detection is (& this is the bigger problem): when u are jumping & u reached the heighest point (the top of the jump), the Y velocity is zero. And when the velocity is zero u can do another jump... nice multijump sysetem...

Julio are u there somewhere in the ether?

CollerbladE
collerblade
 
Posts: 88
Joined: Mon Apr 05, 2010 12:09 pm

Re: Player controller problem

Postby ledahut » Mon Sep 06, 2010 3:08 am

OK, I don't know about the ramp, but there is another way to jump [With material contact].

Just Create two material: one for player, one for the ground.

In NewtonContactsProcess:
Code: Select all
begin
  ThisContact := NewtonContactJointGetFirstContact(contact);
  while ThisContact <> nil do
  begin
  Thismaterial := NewtonContactGetMaterial(ThisContact);
  NewtonMaterialSetContactNormalDirection(Thismaterial ,[b]Ydirection[/b]);
  NewtonMaterialSetContactNormalAcceleration(Thismaterial ,[b]JumpForce[/b])

    ThisContact := NewtonContactJointGetNextContact(contact, ThisContact);
  end;

end;


When these two material collide, you iterate thought every contactPoint and you add a JumpForce in the normal direction.
ledahut
 
Posts: 98
Joined: Mon Jun 21, 2010 8:03 am
Location: France

Re: Player controller problem

Postby collerblade » Tue Sep 07, 2010 5:35 am

hi

i tried but its not working. The problem is, that if im on the ground, the code of the playercontroller nullifies all upward speed & force. So i can set anything it wont work that way.

But i have found the solution. If i can "set myself into air mode", than im able to jump. I have luck, because there is a private variable called m_playerState in customplayercontroller. That not a perfect way, but it works good. So when i jump i set myself to air mode & apply the force as usual (NewtonBodyAddForce) and its works. This variable is also good for my first problem, to detect the player state.
I know that is a very dirty way, but it works good.

My only problem is now, that playercontroller have no air control. How can i set that?
collerblade
 
Posts: 88
Joined: Mon Apr 05, 2010 12:09 pm

Re: Player controller problem

Postby Julio Jerez » Tue Sep 07, 2010 11:47 am

I am aware of the inability fo the player controller to Jump.

I will ask if you can use it as it until I get to the point where I can work on it on a secund pass.
Like I said before, I am focus in in the file format now, so that further work can be tested and preserved.
like it is now it is too difficult to work on joints because each change, also chnges the work of someone else, and also force the people to a new learning curve figure out how the new joint work.

The file format is an attent to remedy that cituation since the joints can be put together graphically and loaded in a game by just linking to the File format library.
the advanced user who like to study the joints can always do that, but the intermediate and beginers is to difficult the way it is now.

can you use as it now and wait onth the new SDK is posted. It won't be 2.25, but maybe 2.26
Julio Jerez
Moderator
Moderator
 
Posts: 12452
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Player controller problem

Postby collerblade » Fri Sep 10, 2010 7:12 am

Thx for the replay.

Ok. I set myself into a sitting & waiting mode :D.

I write the problems (& suggestions) about customplayercontroller. I have found 4 problems only.

1. Is the player in the air or on the ground?
- The solution is simple. U have to write a method, to query m_playerState variable.

2. If the player is on the ground, it blocks newtonbodyaddforce. So its problematic to handle jump & explosions or force fields.
- Maybe the user chage the mode to "air mode"? I doing it now, but that is a problematic solution.

3. The player interacts to strong with its enviroment. Now the mass of my body is 10 (Average human body mass is about 80 kilogram). But i still can push easily other heavy objects (mass over 400).

4. Player step problems.
a. The controller can step up to high objects, if the cannot be pushed away. I tested it on a box. I pushed it to the wall, & when the box reached the wall, sudenely i find myself on the top of the box. (it was 2 times higer than the step-heigh)
b. The controller can't step up to objects with are smaller than the step-height, but they have sloper side than the maximum slope angle.

I think these are the main problems with customplayercontroller.

Have a nice day, and thx: CollerbladE
collerblade
 
Posts: 88
Joined: Mon Apr 05, 2010 12:09 pm

Re: Player controller problem

Postby collerblade » Sat Sep 11, 2010 4:42 am

ÁÁÁÁ. I forget something. Its very important. AIR CONTROL!!!!!
collerblade
 
Posts: 88
Joined: Mon Apr 05, 2010 12:09 pm

Re: Player controller problem

Postby Julio Jerez » Sat Sep 11, 2010 11:01 am

what do you mean Air control?
Julio Jerez
Moderator
Moderator
 
Posts: 12452
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Player controller problem

Postby collerblade » Sat Sep 11, 2010 6:29 pm

Have u ever played Quake Doom Unreal? fps?

Air control: player can move in air (not just on the ground). Now in your implementation have no air control (meains 0% air control). Air control can be defined as a percent value from 0 to 100%. This value mean how fast u can walk in air compared to the movement speed on the ground.

Air control is physicaly unrealistic of course, because u cant move when u are in the air (except jumppacks), but its also nessesery. For example player want to jump from a window to a bus beneath. In a real situation the player can jump shorter or longer, but the playercontroller have a contant speed, so the jump will be as the same every times. Secondly example: the player want to jump up to a box in front of hisself. If he jumps, he has only upward speed component, so he will fall down to his original position.
The fps games solve this problems, by adding eg.: 10% air control. So the if i jump, & press forward i can jump up to the box or i can boost myself to get the bus :D.

I hope u understand me even if i have bad english :-).

collerbladE
Last edited by collerblade on Sat Sep 11, 2010 6:36 pm, edited 1 time in total.
collerblade
 
Posts: 88
Joined: Mon Apr 05, 2010 12:09 pm

Next

Return to General Discussion

Who is online

Users browsing this forum: No registered users and 131 guests