Gamestudio Links
Zorro Links
Newest Posts
Zorro 2.70
by jcl. 09/29/25 09:24
optimize global parameters SOLVED
by dBc. 09/27/25 17:07
ZorroGPT
by TipmyPip. 09/27/25 10:05
assetHistory one candle shift
by jcl. 09/21/25 11:36
Plugins update
by Grant. 09/17/25 16:28
AUM Magazine
Latest Screens
Rocker`s Revenge
Stug 3 Stormartillery
Iljuschin 2
Galactic Strike X
Who's Online Now
1 registered members (TipmyPip), 18,633 guests, and 5 spiders.
Key: Admin, Global Mod, Mod
Newest Members
krishna, DrissB, James168, Ed_Love, xtns
19168 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 1 of 2 1 2
Few questions about PhysX #368919
04/29/11 14:16
04/29/11 14:16
Joined: May 2009
Posts: 5,377
Caucasus
3run Offline OP
Senior Expert
3run  Offline OP
Senior Expert

Joined: May 2009
Posts: 5,377
Caucasus
OK, so as I realized, in "physics" forum, no one was able to answer me.
That the main reason for that I've decided to ask my questions here.
I'm trying to make simple 2D movement, with BOX hull shape for player.
I need to move character only in X coordinates, all other coordinated should be locked.
I need physic object to be able to turn only in TILT, all other angles should be locked.
I want character to react for all forces and gravity as well, not only movement forces by keys.
Here you can download demo of what I've tried to do:
Download link
And you can see it here (for those lazy ones):
Code:
///////////////////////////////////////////////////////////////////////////////
#include <acknex.h>
#include <default.c>
#include <ackphysX.h>
///////////////////////////////////////////////////////////////////////////////
STRING* test_wmb = "test.WMB";
///////////////////////////////////////////////////////////////////////////////
action object()
{
	pXent_settype(my,PH_RIGID,PH_BOX); // dynamic box
	pXent_setskinwidth(my,0); 
	pXent_setccdskeleton(my,vector(0,0,0),1); 
}
///////////////////////////////////////////////////////////////////////////////
function set_camera()
{
	vec_set(camera.x,vector(my.x,my.y - 700,my.z));
	camera.pan = 90;
	camera.tilt = 0;
}
///////////////////////////////////////////////////////////////////////////////
action hero()
{
	VECTOR temp;
	player = my;
	pXent_settype(my,PH_CHAR,PH_BOX); // box character
	wait(1); // wait one frame as manual says
	pXent_setskinwidth(my,0);  
	pXent_setccdskeleton(my,vector(0,0,0),1); 
	while(1)
	{
		temp.x = 10 * (key_d - key_a) * time_step; 
		temp.y = 10 * (key_w - key_s) * time_step; 
		temp.z = 10 * (key_q - key_e) * time_step;
		pXent_moveglobal(my,temp,nullvector);  		
		//pXent_movechar(my,temp,nullvector,0);
		set_camera();
		wait(1);
	}
}
///////////////////////////////////////////////////////////////////////////////
function main()
{
	fps_max = 60;
	physX_open(); // load physX
	level_load(test_wmb); // load level
	wait(3); // wait for 3 frames
	pX_setccd(1); // activate CCD
	// make nice 2D physics
	pXent_setbodyflagall(NX_BF_FROZEN_POS_Y|NX_BF_FROZEN_PAN|NX_BF_FROZEN_ROLL,1);	
	pX_setgravity(vector(0,0,-9.81)); // apply earth gravity
}
///////////////////////////////////////////////////////////////////////////////

So, my questions are:
* how to lock all physic objects in Y, Z, PAN, ROLL (pXent_setbodyflagall doesn't help)?
* how to make PH_CHAR object to react on other forces (for example, gravity and explosions)?
* how to make character collide with other RIGID bodies properly (so they don't pass throw each other, CCD doesn't help)?


Looking for free stuff?? Take a look here: http://badcom.at.ua
Support me on: https://boosty.to/3rung
Re: Few questions about PhysX [Re: 3run] #368981
04/30/11 08:14
04/30/11 08:14
Joined: Aug 2000
Posts: 1,140
Baunatal, Germany
Tobias Offline

Moderator
Tobias  Offline

Moderator

Joined: Aug 2000
Posts: 1,140
Baunatal, Germany
I think this cant work, PhysX body flags and forces are for physics objects, not for character controllers.

A character controller is controlled not by physics but by your script. If you want an axis to be frozen for a character controller then just dont move or rotate it along this axis.

Re: Few questions about PhysX [Re: Tobias] #369031
04/30/11 20:13
04/30/11 20:13
Joined: May 2009
Posts: 5,377
Caucasus
3run Offline OP
Senior Expert
3run  Offline OP
Senior Expert

Joined: May 2009
Posts: 5,377
Caucasus
OK, but what about applying forces to character? And how can I make proper collisions between rigid and character objects? Cause the way they collide now, it's same if I use c_move with physics.


Looking for free stuff?? Take a look here: http://badcom.at.ua
Support me on: https://boosty.to/3rung
Re: Few questions about PhysX [Re: 3run] #369175
05/02/11 13:14
05/02/11 13:14
Joined: Jul 2000
Posts: 28,024
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 28,024
Frankfurt
Forces can obviously not move an object when you already move it with pXent_moveglobal. An object is either a character that is moved by your script, or a physics object that is moved by forces - you have to decide.

Character controllers are supposed to perform normal collision detection with the level. Make sure that collision is set up properly, i.e. they don't belong to the same collision group or something like that.


Re: Few questions about PhysX [Re: jcl] #369185
05/02/11 14:25
05/02/11 14:25
Joined: May 2009
Posts: 5,377
Caucasus
3run Offline OP
Senior Expert
3run  Offline OP
Senior Expert

Joined: May 2009
Posts: 5,377
Caucasus
OK, locking positions and angles of character are clear for me now.
Do I need to make for example forces from explosion same as with c_move?
And I still have problem with collusions between character and rigid bodies. Example:
Rigid body in the corner, and I move character to it, so character pushes rigid body, and passes throw it.
Please check my script above, and tell me if I'm doing anything wrong. I didn't set collusion groups.


Looking for free stuff?? Take a look here: http://badcom.at.ua
Support me on: https://boosty.to/3rung
Re: Few questions about PhysX [Re: 3run] #369308
05/03/11 13:36
05/03/11 13:36
Joined: Jul 2000
Posts: 28,024
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 28,024
Frankfurt
For simulating an explosion, you could change the entity from a character controller to a physics object - maybe a ragdoll - and afterwards back to a character controller.

I don't know the reason of your collision problem, but other people also had problems with character controllers, so we'll upload a sample demo in the next days that walks a character with collision detection and shows the differences between pXent_move and c_move.

Re: Few questions about PhysX [Re: jcl] #369311
05/03/11 13:59
05/03/11 13:59
Joined: May 2009
Posts: 5,377
Caucasus
3run Offline OP
Senior Expert
3run  Offline OP
Senior Expert

Joined: May 2009
Posts: 5,377
Caucasus
I can even upload a video, if you want me to, character passes throw rigid buddy and then they more together.
Also, I found hard to make proper gravity with the use of "USE_BOX", gravity starts pulling player down when he is near edge.
Thats caused by an ellipsoid hull of c_trace I guess. Is there anyway to make BOX like trace? USE_BOX doesn't do that.


Looking for free stuff?? Take a look here: http://badcom.at.ua
Support me on: https://boosty.to/3rung
Re: Few questions about PhysX [Re: 3run] #369328
05/03/11 16:13
05/03/11 16:13
Joined: Feb 2010
Posts: 886
Random Offline
User
Random  Offline
User

Joined: Feb 2010
Posts: 886
Quote:
For simulating an explosion, you could change the entity from a character controller to a physics object - maybe a ragdoll - and afterwards back to a character controller.


Yes, but to do that, you have to delete the ragdoll and create the player new at the same place.
If you let the player turn into a ragdoll, and then start the player function again with the same model, you will become a unmoveable, wired on the groung laying charector, whith you can`t really conrtoll...

Last edited by Random; 05/03/11 16:18.


Re: Few questions about PhysX [Re: Random] #369727
05/06/11 15:01
05/06/11 15:01
Joined: Jul 2000
Posts: 28,024
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 28,024
Frankfurt
Random: No, permanently deleting or creating ragdolls is certainly not such a good idea. Better create your ragdolls and character controller already at game start, and switch player model control between them dependent on the situation. At least that's what the grown-up game programmers are supposed to do in commercial games.

3run: In all our levels collision works fine with character controllers. It's very simple, so I'm not sure why you have problems. Look here for a short script that demonstrates all 4 movement modes:

http://manual.3dgamestudio.net/pXent_move.htm

It uses a new function, pXent_move, which you don't have, but in version 8.20 you can just call pXent_moveglobal instead. pXent_move will replace pXent_moveglobal/local in next week's new public beta.

Movement with gravity is covered in the walking script example in the manual. For detecting the ground per USE_BOX, better use a flat disk collision shape rather than an ellipsoid.

Re: Few questions about PhysX [Re: jcl] #369734
05/06/11 16:37
05/06/11 16:37
Joined: May 2009
Posts: 5,377
Caucasus
3run Offline OP
Senior Expert
3run  Offline OP
Senior Expert

Joined: May 2009
Posts: 5,377
Caucasus
Something strange happened, I can't move character via "pXent_moveglobal" anymore.
I just downloaded demo, I posted in first post, and it doesn't work...
Player changes it's position to the "nullvector" and doesn't move.
It moves if I do it like this: "dist.x += 10 * (key_w - key_s) * time_step;"
But if I do it like this, character passes throw level blocks (but collides with Ridig bodies).
Same happens if I use the example script you've posted link to.
I can move character normally with "pXent_movechar", but I'm getting problem with collisions again:
Example one:

Example two:

Here is example I tried to get working:
Code:
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
#include <acknex.h>
#include <default.c>
#include <ackphysX.h>
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
action box_obj()
{
	pXent_settype(my,PH_RIGID,PH_BOX); 
}
action ball_obj()
{
	pXent_settype(my,PH_RIGID,PH_SPHERE);
}
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
var my_height;
VECTOR dist;
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
action hero()
{
	pXent_settype(my,PH_CHAR,PH_BOX); 
	wait(-1);
	while(1)
	{
		DEBUG_VAR(my_height,30);
		my_height = c_trace(my.x,vector(my.x,my.y,my.z-500), IGNORE_ME|USE_BOX);
		if(my_height > 5){dist.z -= 1 * time_step;}else{dist.z = 0;}
		dist.x = 10 * (key_d - key_a) * time_step; 
		dist.y = 0;
		//pXent_moveglobal(my,dist,nullvector);  		
		pXent_movechar(my,dist,nullvector,0);
		vec_set(camera.x,vector(my.x,my.y - 700,my.z));
		wait(1);
	}
}
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
function main()
{
	fps_max = 60;
	physX_open();
	level_load("test.WMB"); 
	wait(3);
	vec_set(camera.pan,vector(90,0,0));
	pXent_setbodyflagall(NX_BF_FROZEN_POS_Y|NX_BF_FROZEN_PAN|NX_BF_FROZEN_ROLL,1);	
	pX_setgravity(vector(0,0,-9.81)); 
}
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////

One more problem I found with making gravity for character, take a look at the screen:

At this position, gravity starts applying, cause trace returns far distance to ground.
But cause characters hull is BOX like, it doen't move down. Example is in script above.
Could you please check example I posted above, may be reason for all bugs I get with collusions is bad scripting?
Could you please give me an idea for workaround problem with gravity? Or may be in next update you'll make BOX shape for trace?
How do I change to "flat disk" shape for trace? I've never heard about it.


Looking for free stuff?? Take a look here: http://badcom.at.ua
Support me on: https://boosty.to/3rung
Page 1 of 2 1 2

Moderated by  old_bill, Tobias 

Gamestudio download | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1