Gamestudio Links
Zorro Links
Newest Posts
Data from CSV not parsed correctly
by EternallyCurious. 04/18/24 10:45
StartWeek not working as it should
by Zheka. 04/18/24 10:11
folder management functions
by VoroneTZ. 04/17/24 06:52
lookback setting performance issue
by 7th_zorro. 04/16/24 03:08
zorro 64bit command line support
by 7th_zorro. 04/15/24 09:36
Zorro FIX plugin - Experimental
by flink. 04/14/24 07:48
Zorro FIX plugin - Experimental
by flink. 04/14/24 07:46
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
3 registered members (MadJack, AndrewAMD, Quad), 540 guests, and 1 spider.
Key: Admin, Global Mod, Mod
Newest Members
EternallyCurious, 11honza11, ccorrea, sakolin, rajesh7827
19046 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
make an arrow stick to the hit entity #447223
11/26/14 18:47
11/26/14 18:47
Joined: Jul 2009
Posts: 85
A
Altarius Offline OP
Junior Member
Altarius  Offline OP
Junior Member
A

Joined: Jul 2009
Posts: 85
Hi,

Im using a model for my projectile arrow and im trying to figure out how to make it stick to the entity it hit, following his animation and movement.

I have started something using "ent_getvertex" but im kinda lost.

Anyone can give me a hint plz.

Thx.

Re: make an arrow stick to the hit entity [Re: Altarius] #447224
11/26/14 20:09
11/26/14 20:09
Joined: Jul 2008
Posts: 2,107
Germany
rayp Offline

X
rayp  Offline

X

Joined: Jul 2008
Posts: 2,107
Germany
Hi.

Here's an example how to place a sprite that will follow another entity ( taken from: http://www.opserver.de/ubb7/ubbthreads.php?ubb=showflat&Number=414718 )
Code:
define selected skill100

void selection_sprite(){ // fex a circle sprite
	set(my,PASSABLE|TRANSLUCENT);
	my.tilt += 90;
	while(you){	
                vec_set(my.x, you.x);	
		if (you) if (!you.selected) break;
		wait(1);
	}
	wait(1);
	ptr_remove(me);
}

..
my.selected = 1;
ent_create("circle.tga", vector(my.x, my.y, my.z), selection_sprite);

..
wait(-1);
my.selected = 0;



Besides the following commands where made for that:
Code:
vec_for_vertex, vec_for_bone, vec_set

example ( taken from here http://www.opserver.de/ubb7/ubbthreads.php?ubb=showflat&Number=404673 )
Code:
VECTOR _p,_a;
vec_for_bone(_p, ThePlayer, "Righthand");
ang_for_bone(_a, ThePlayer, "Righthand");
vec_set(Axe.x, _p.x); //set the axe to the right hand
vec_set(Axe.pan, _a); //and rotate it with the animation of the bone



edit: If you want to stick a model to last hit position you could do it like this ( just wrote it, but didnt test )
Code:
.
..
...
c_trace (...);
if (you){                   // hit entity?
   you.skill1 = hit.vertex; // store vertexnr in skill1
   example_arrow (you);     // create arrow at hit pos
}
...
..
.
void example_arrow (ENTITY* _ent){
   proc_mode |= PROC_GLOBAL;
   if (!_ent) return;
   ENTITY* your_mdl = ent_create ("arrow.mdl", nullvector, NULL);
   if (!your_mdl) return; // creation error?
   set (your_mdl, PASSABLE);
   while (_ent && your_mdl){ // hit-you and arrow-mdl != NULL
      vec_for_vertex (your_mdl.x, _ent, _ent.skill1); // set pos of saved vertexnr
      wait (1);
   }
   wait (1);
   ptr_remove (your_mdl);
}


Greets

Last edited by rayp; 11/26/14 21:20. Reason: corrected some things

Acknex umgibt uns...zwischen Dir, mir, dem Stein dort...
"Hey Griswold ... where u gonna put a tree that big ?"
1998 i married my loved wife ... Sheeva from Mortal Kombat, not Evil-Lyn as might have been expected
rayp.flags |= UNTOUCHABLE;
Re: make an arrow stick to the hit entity [Re: rayp] #447227
11/26/14 20:41
11/26/14 20:41
Joined: Jul 2009
Posts: 85
A
Altarius Offline OP
Junior Member
Altarius  Offline OP
Junior Member
A

Joined: Jul 2009
Posts: 85
Nice thx a lot.

But i dont know wich part of the entity the arrow gonna hit, so i cant know wich bone this part are controled by. That's why im suposing to use ent_getvertex for find the closest vertex of the hit spot,when the arrow hit the model for
determinate where the arrow need to stick, then vec_for_vertex for followind the model animation and movement.

But maybe im wrong.


Last edited by Altarius; 11/26/14 20:44.
Re: make an arrow stick to the hit entity [Re: Altarius] #447228
11/26/14 20:59
11/26/14 20:59
Joined: Jul 2008
Posts: 2,107
Germany
rayp Offline

X
rayp  Offline

X

Joined: Jul 2008
Posts: 2,107
Germany
Yes your idea is right. Please see my last edit ( just done ). Its a simple example of that. After a c_trace the closet vertex to hitposition will be saved in hit - entitys skill1. Then a function creates a arrow model ( or whatever ). This one will be placed at position taken from vertex nr saved in skill1. Hope it helps.


Acknex umgibt uns...zwischen Dir, mir, dem Stein dort...
"Hey Griswold ... where u gonna put a tree that big ?"
1998 i married my loved wife ... Sheeva from Mortal Kombat, not Evil-Lyn as might have been expected
rayp.flags |= UNTOUCHABLE;
Re: make an arrow stick to the hit entity [Re: rayp] #447229
11/26/14 21:07
11/26/14 21:07
Joined: Jul 2009
Posts: 85
A
Altarius Offline OP
Junior Member
Altarius  Offline OP
Junior Member
A

Joined: Jul 2009
Posts: 85
Cool! im gonna try this. Thx again .


Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

Gamestudio download | chip programmers | 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