physical

Posted By: GaniX

physical - 08/06/13 19:54

hello all.
I'm trying to make a code of a fps game , the shot will be simulated using an xray for a trace.
the problem I have is that: when one shoots(a trace hit when mouse left click) a metal box for example, this box still like a solid box and dotīt move , I want this box to make a more realistic movement using the physics of the shot, using the physical movements.
but I have not much idea of ​​how to make the code because i have not so much idea how is this language is tray the physics , can anybody help me?
Posted By: Random

Re: physical - 08/06/13 22:19

I suppose you use PhysX. Do you know how to initialize PhysX?
And post the script you wrote, let`s see what you have done there and then I am going to show you how to actually use PhysX wink
Posted By: Ch40zzC0d3r

Re: physical - 08/07/13 07:20

Well, there are some more ways to do this.
One idea would be to simply write a skill (lets take 23) and put it on a specific value (lets take 1337). Now in your trace you check for you. If you is valid check the skill, if its 1337 you have to create a vector (depending on the mass of the box and strength of the weapon). You also need to apply the force on the position where you hit the box, here we will use "USE_POLYGON" in the trace so we can later apply it on the hit position:

Code:
if(c_trace(..))
{
	if(you)
	{
		if(you.skill23 == 1337)
		{
			VECTOR vForce;
			vec_set(vForce, vector(100, 0, 0));
			vec_rotate(vForce, pTraceHit.rotation);
			pXent_addforceglobal(you, vForce, hit.x);
		}
	}
}



Edit: Heres a little preview how it will look like: www.youtube.com/watch?v=daRrCOQxsiY
Posted By: GaniX

Re: physical - 08/07/13 15:10

s for help.
ok i study the code off the erthball8 of the samples to make that, but still have a problem.
if the trace hit a box in the superior part the box must rotate back , but in this case thats not happend . but is a good start to study this.

Ch40zzC0d3r: can you pls explain to me something more about your idea because its sound like something i need
Posted By: Ch40zzC0d3r

Re: physical - 08/07/13 15:44

Well, I gave you the code to archieve this, you just need to pass the right arguments to the c_trace, also pTraceHit.rotation in my example is camera.pan for sure.
Posted By: Random

Re: physical - 08/07/13 17:17

Fist you have to initialize physX.
Do it in your main script:

Code:
function main()
...
	wait(3);
	physX_open();
	pX_setgravity(vector(0,0,-10));
	pX_setccd(1);
	wait(1); 
...



now you can write a simple script for a box for example.
Code:
action PhysX_box()
{
pXent_settype(my,PH_RIGID,PH_BOX);
	pXent_setelasticity(my,80);
	pXent_setdamping(my,20,5);
}



and now you can shoot a box
Posted By: GaniX

Re: physical - 08/08/13 16:36

ok thanks now i study all you say, thanks
Posted By: GaniX

Re: physical - 08/10/13 22:01

ok thanks for helping.
i have a new problem.
the probelm is the box, when i shoot the box can move trought the wall or floor, i read something about use the pX_setccd and pXent_setccdskeleton;then i put on the main this physX_load(); and in the acction of box this pX_setccd ( 1 );
pXent_setccdskeleton( box, vector(0, 0, 0), 1 ); and test, but the problem is continues.
help pls !!!!
thank
© 2024 lite-C Forums