physx unregister / disable ent bugs ?

Posted By: Reconnoiter

physx unregister / disable ent bugs ? - 03/21/17 12:29

Howdy,

I use gs3d physx in my project and when I kill an enemy (registered as PH_CHAR / character -> pXent_settype(my, PH_CHAR, PH_CAPSULE);) I want to unregister or disable it so it becomes passable. However as soon as I either do pXent_enable(my, 0); or pXent_settype(my, 0, 0); , all other enemies becomes bugged and rotate randomly and move different directions than they normally would. Any idea how to solve this?
Posted By: alibaba

Re: physx unregister / disable ent bugs ? - 03/21/17 12:45

Sounds like a memory leak to me. Usually 3DGS handles the removal of physx ents himself. Have you used on_ent_remove anywhere?
Posted By: Reconnoiter

Re: physx unregister / disable ent bugs ? - 03/21/17 14:11

Ty for replying. I dont have any on_ent_remove's. Also it seems like I have it only for the characters, e.g. when I register e.g. a crate as a PH_CHAR and unregister after a wait it doesn't seem to cause any problems. So I think I am making a mistake in my character code somewhere but I dont know what.

Some outstanding code:
Code:
//Set Collision Event
for (you = ent_next (NULL); you; you = ent_next (you)) {  
	if (you) {
		if (you.TYPE == IS_ITEM || you.TYPE == IS_PROP_RIGID) pXent_setcollisionflag(my, you, NX_NOTIFY_ON_START_TOUCH);
	} 
}


But I unlink them through NX_IGNORE_PAIR before unregistering.

Also when I unregister I also set the following (dont know if this matters):
set(my, PASSABLE);
my.emask &= ~DYNAMIC;
Posted By: Reconnoiter

Re: physx unregister / disable ent bugs ? - 03/21/17 19:47

Hmm for some reason the doing following before registering as PH_CHAR does make it more stable (but still can bug out enemies after a while):
Code:
pXent_settype(my,0,0);
my.emask |= DYNAMIC;
wait(1);


Anyone know what is happening here?
Posted By: painkiller

Re: physx unregister / disable ent bugs ? - 03/22/17 09:57

I've used pXent_settype(my,0,0); also in a test level with enemies and didn't have that issue, although I didn't reset the dynamic flag afterwards. maybe the problem is related to resetting that flag?
Posted By: Reconnoiter

Re: physx unregister / disable ent bugs ? - 03/22/17 13:47

Ty for reply, I tried that but it doesn't seem to make a difference. Also maybe important to note: only the enemies bug out but never the player actor (even while they share alot of functions). I tried comment the AI only lines out but doesn't seem to make a difference to. Only the 'player' pointer is different ofcourse.

Also you run Shade-c evo right Painkiller? So that should not be it than.
Posted By: painkiller

Re: physx unregister / disable ent bugs ? - 03/23/17 11:40

Originally Posted By: Reconnoiter
Ty for reply, I tried that but it doesn't seem to make a difference. Also maybe important to note: only the enemies bug out but never the player actor (even while they share alot of functions). I tried comment the AI only lines out but doesn't seem to make a difference to. Only the 'player' pointer is different ofcourse.

Also you run Shade-c evo right Painkiller? So that should not be it than.


yes, I'm running Shade-C too. Maybe you are using any global variable for the enemies that causes a conflict between them? or a memory leak issue?
Posted By: Reconnoiter

Re: physx unregister / disable ent bugs ? - 03/24/17 16:26

@Painkiller, in your tests, did you use pXent_move?
After exhaustive testing (with stripped down code, no player and only a couple of enemies and terrain) it seems there becomes something wrong with pXent_move only, the rest seems to work well. Also I think that pXent_move bugs out enemies/player only during the frame(s) the enemy get unregistered, hence why the player rarely bugs out cause pXent_move is not constantly triggered for the player but is for enemies.
Posted By: painkiller

Re: physx unregister / disable ent bugs ? - 03/25/17 11:45

Originally Posted By: Reconnoiter
@Painkiller, in your tests, did you use pXent_move?
After exhaustive testing (with stripped down code, no player and only a couple of enemies and terrain) it seems there becomes something wrong with pXent_move only, the rest seems to work well. Also I think that pXent_move bugs out enemies/player only during the frame(s) the enemy get unregistered, hence why the player rarely bugs out cause pXent_move is not constantly triggered for the player but is for enemies.


I use forces to move the characters, so yeah maybe it could be an issue with pXent_move
Posted By: Reconnoiter

Re: physx unregister / disable ent bugs ? - 03/25/17 16:52

Ditching pXent_move and pXent_rotate seems to have solved the problem and is also much cooler imo being able to push away enemies etc. laugh
What function do you use to move entities around? pXent_addvelcentral? Movement is still a bit floaty even though I have set pXent_setdamping to 100%.
Posted By: painkiller

Re: physx unregister / disable ent bugs ? - 03/26/17 12:37

I use pXent_addvelcentral or pXent_addforcecentral and set damping to 1000
Posted By: Reconnoiter

Re: physx unregister / disable ent bugs ? - 03/26/17 14:42

Ty, that is better now (didn't know it could be higher than 100). What do you use to rotate?
Setting pan directly seems to not store it correctly (except in combination with pXent_enable but that is rather slow) and pXent_addtorquelocal/global seems to give weird results.
Posted By: painkiller

Re: physx unregister / disable ent bugs ? - 03/26/17 15:36

I use pXent_rotate, I don't have issues with it in my case.

If I have enough time on the following days I will publish a small demo game as open source for the winter contest so everyone can see how to use physx for characters as rigid bodies and some game mechanics.
Posted By: Reconnoiter

Re: physx unregister / disable ent bugs ? - 03/29/17 12:06

Originally Posted By: painkiller
If I have enough time on the following days I will publish a small demo game as open source for the winter contest so everyone can see how to use physx for characters as rigid bodies and some game mechanics.
, that would be helpful laugh . I got the rotation now working when doing both pXent_rotate (ent, nullvector, rotate_ang); vec_set(ent.pan, rotate_ang); (when doing only pXent_rotate alone it is less smooth for me). It seems more stable now but I got to do some long play sessions first to be sure.
© 2024 lite-C Forums