1 registered members (7th_zorro),
1,300
guests, and 3
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
How to make a Plasma Grenade like in Halo 1- 3 ?
#362456
03/08/11 12:55
03/08/11 12:55
|
Joined: Jun 2008
Posts: 402 Germany
sebbi91
OP
Senior Member
|
OP
Senior Member
Joined: Jun 2008
Posts: 402
Germany
|
Hi again, I want to use grenades in my game that sticks at objects. It's like the "Plasma Grenade" in Halo 1- 3? Who don't know the game: In the game is a kind of grenade that sticks at modells. Here you can see it in action: plasma grenade sample video and here is something to read: Plasma grenade text Ok I think you know what I want. I tried it by using the PhysX-Engine to throw the grenate. Here is my hopeless try for the grenade.
action pl_grenade_act()
{
set(my,CAST|SHADOW|PASSABLE);
my.emask|=ENABLE_SHOOT|ENABLE_BLOCK|ENABLE_IMPACT|ENABLE_ENTITY|ENABLE_FRICTION;
my.push=50;
my.waittime=40;
pXent_settype(me,PH_RIGID,PH_SPHERE);
pXent_setmass (my, 10);
pXent_setfriction (my, 80);
pXent_setdamping (my, 10, 10);
pXent_setelasticity (my, 50);
my.lightrange=70;
my.red=0;
my.blue=100;
my.green=20;
pXent_settype(me, PH_RIGID, PH_SPHERE);
wait(1);
while(1)
{
//get sticky now:
c_trace (my.x,you.x,IGNORE_ME|IGNORE_PASSABLE|SCAN_TEXTURE);
if(you&&my.waittime<=36)
{
pXent_settype(me,NULL,NULL);
VECTOR hit_vec;
CONTACT* contact1 =ent_getvertex(you,NULL,hit.vertex);
vec_for_ent (contact1.x, my);
vec_for_vertex (hit_vec,you,hit.vertex);
my.x=hit_vec.x;
}
//handle time counter and explosion
...
wait(1);
}
}
My problem is to handle that the grenade find the next vertex to stick on it. I've read something about. hit.vertex but cant handle to use it. I think its an hard way to get it working with the c_trace event. My next try was to use the physX engine to get sure that the grenade collides with another PhysX-modell. I used something like that:
pXent_setcollisionflag(me,enemy,NX_NOTIFY_ON_START_TOUCH);
my.event=get_sticky;
But it doesn't work. Any Ideas? BTW I am using 3D Gamestudio A8-Commercial for that. regards sebbi
3D-Gamestudio A8 - Commercial
|
|
|
Re: How to make a Plasma Grenade like in Halo 1- 3 ?
[Re: TheShooter]
#362499
03/08/11 15:36
03/08/11 15:36
|
Joined: Dec 2008
Posts: 1,660 North America
Redeemer
Serious User
|
Serious User
Joined: Dec 2008
Posts: 1,660
North America
|
Make an entity that flies through the air with c_move and the USE_POLYGON flag. When it hits another entity, you can make it stick by calculating the distance vector between the grenade and the hit entity and then set the grenade to the position of the hit entity + the calculated distance vector. Here's an untested example action explaining what I mean:
#define reldist_x skill1
#define reldist_y skill2
#define reldist_z skill3
#define absdist_x skill4
#define absdist_y skill5
#define absdist_z skill6
#define entity_handle skill7
action grenade()
{
my.reldist_x = 16; // forward velocity
my.reldist_y = 0;
my.reldist_z = 0;
my.absdist_x = 0;
my.absdist_y = 0;
my.absdist_z = 16; // the grenade flies upwards at first.
while( my ) // while I exist
{
if( !is(my,FLAG1) ) // "flying through the air" mode
{
my.absdist_z -= time_step; // the grenade flies downward over time.
c_move( my, my.reldist_x, my.absdist_x, USE_POLYGON );
if( trace_hit && you ) // hit an entity
{
// remember the entity I hit with a handle
my.entity_handle = handle( you );
// go to "sticky" mode
set( my, FLAG1 );
}
}
else // "sticky" mode
{
your = ptr_for_handle( my.entity_handle );
if( your ) // only do this if the entity still exists, of course (otherwise we get a pointer error)
{
// In sticky mode, I repurpose my.absdist to be the position of the grenade + the distance between the grenade and the hit entity.
vec_diff( my.absdist_x, my.x, your.x );
vec_add( my.absdist_x, my.x );
vec_set( my.x, my.absdist_x );
}
}
wait(1);
}
}
When this action is assigned to an entity, it will fly through the air with an initial upward velocity and begin to descend. When it hits another entity, it enters "sticky mode" and begins to stick to the entity! Hope that helped.
Last edited by Redeemer; 03/08/11 15:40.
|
|
|
Re: How to make a Plasma Grenade like in Halo 1- 3 ?
[Re: Redeemer]
#362509
03/08/11 16:35
03/08/11 16:35
|
Joined: Jun 2008
Posts: 402 Germany
sebbi91
OP
Senior Member
|
OP
Senior Member
Joined: Jun 2008
Posts: 402
Germany
|
first of all thanks for your posts. it works but its not sticked at a vertex-point. it means if the grenade is at the leg it doesn't sticked at the vertex at the leg, it's still in the position. But thanks for your try anyway any idea how to put it at the vertex ? regards Sebbi
3D-Gamestudio A8 - Commercial
|
|
|
Re: How to make a Plasma Grenade like in Halo 1- 3 ?
[Re: darkinferno]
#362681
03/09/11 06:07
03/09/11 06:07
|
Joined: Aug 2003
Posts: 7,439 Red Dwarf
Michael_Schwarz
Senior Expert
|
Senior Expert
Joined: Aug 2003
Posts: 7,439
Red Dwarf
|
just place the grenade at the nearest vertex, that should do it
"Sometimes JCL reminds me of Notch, but more competent" ~ Kiyaku
|
|
|
Re: How to make a Plasma Grenade like in Halo 1- 3 ?
[Re: Michael_Schwarz]
#362739
03/09/11 14:54
03/09/11 14:54
|
Joined: Jun 2008
Posts: 402 Germany
sebbi91
OP
Senior Member
|
OP
Senior Member
Joined: Jun 2008
Posts: 402
Germany
|
just place the grenade at the nearest vertex, that should do it And this is exactly what I want to have Please, could you tell me how? best regards sebbi
3D-Gamestudio A8 - Commercial
|
|
|
Re: How to make a Plasma Grenade like in Halo 1- 3 ?
[Re: darkinferno]
#362968
03/10/11 14:58
03/10/11 14:58
|
Joined: Jun 2008
Posts: 402 Germany
sebbi91
OP
Senior Member
|
OP
Senior Member
Joined: Jun 2008
Posts: 402
Germany
|
@ Michael_Schwarz: Please could you tell me how? I can't get it working. @darkinferno: The thing with walls is not the problem. I have an system that kows if the ground is a map entity or an enemy (like, Vehicles or humans) the only thing what i want to know is how to put the grenade at the models next vertex. i dont have enough time to go into this now.. sorry No problem, but thanks anyway for your help. kind regards Sebbi
3D-Gamestudio A8 - Commercial
|
|
|
Moderated by mk_1, Perro, rayp, Realspawn, Rei_Ayanami, rvL_eXile, Spirit, Superku, Tobias, TSG_Torsten, VeT
|