Gamestudio Links
Zorro Links
Newest Posts
AlpacaZorroPlugin v1.3.0 Released
by kzhao. 05/22/24 13:41
Free Live Data for Zorro with Paper Trading?
by AbrahamR. 05/18/24 13:28
Change chart colours
by 7th_zorro. 05/11/24 09:25
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
1 registered members (Akow), 1,361 guests, and 9 spiders.
Key: Admin, Global Mod, Mod
Newest Members
AemStones, LucasJoshua, Baklazhan, Hanky27, firatv
19055 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
create ent with c trace #406839
08/30/12 19:36
08/30/12 19:36
Joined: Apr 2008
Posts: 245
GameScore Offline OP
Member
GameScore  Offline OP
Member

Joined: Apr 2008
Posts: 245
i`m not sure how to call this post

the thing what i wanna do is to create a entity
in the front or in the back or where a trace hits the player
and keep a bit distance to the player, maybe a dist of 10 or 50 quants to the hit.x ponit
it should be move and rotate with the player

some ideas how to handle this?
create an ent by a trace hit, i can do myself, but the distance thing i have a prolem with

Re: create ent with c trace [Re: GameScore] #406842
08/30/12 19:59
08/30/12 19:59
Joined: Sep 2009
Posts: 993
Budapest
Aku_Aku Offline
User
Aku_Aku  Offline
User

Joined: Sep 2009
Posts: 993
Budapest
Why the distance is the problem?

Re: create ent with c trace [Re: Aku_Aku] #406843
08/30/12 20:03
08/30/12 20:03
Joined: Apr 2008
Posts: 245
GameScore Offline OP
Member
GameScore  Offline OP
Member

Joined: Apr 2008
Posts: 245
when the trace hits
i create a ent like this

Code:
some_ent = ent_create ("ent.mdl",hit.x,dosome);



how can i convert the hit x to a point 10 or 50 quants before hit.x
anywhere on the player?

Re: create ent with c trace [Re: GameScore] #406844
08/30/12 20:22
08/30/12 20:22
Joined: Mar 2011
Posts: 3,150
Budapest
sivan Offline
Expert
sivan  Offline
Expert

Joined: Mar 2011
Posts: 3,150
Budapest
create a vector to origin, another to hit, substract them (hit-orig), store its length, store another value which is less by the desired distance, use normalize to decrease the full length to the shorter length, and add it to origin vector to get the point.


Free world editor for 3D Gamestudio: MapBuilder Editor
Re: create ent with c trace [Re: sivan] #406909
09/01/12 16:04
09/01/12 16:04
Joined: Apr 2008
Posts: 245
GameScore Offline OP
Member
GameScore  Offline OP
Member

Joined: Apr 2008
Posts: 245
cant follow you at all

the 1st, create a origin and a hit
and subtract them
like this

Code:
vec_set(vec_origin,vector(player.x,player.y,player.z));
vec_set(vec_hit,hit.x);
vec_sub(vec_hit,vec_origin);


and store its length like this?
Code:
var length=vec_length(vec_hit);
var distance=50;

//how to go on?
vec_normalize(length,distance);
vec_add(vec_origin,length);

anyent = ent_create ("ent.mdl",vec_origin,doanything);


Re: create ent with c trace [Re: GameScore] #406910
09/01/12 17:01
09/01/12 17:01
Joined: Jun 2009
Posts: 2,210
Bavaria, Germany
Kartoffel Offline
Expert
Kartoffel  Offline
Expert

Joined: Jun 2009
Posts: 2,210
Bavaria, Germany
I would do it like this:
(should be the same as sivan's suggestion)

Code:
VECTOR* trace_vec;
vec_set(trace_vec, [vec from trace start to trace hit]);

var dist = vec_length(trace_vec);
vec_normalize(trace_vec, dist - 50); // keep 50 quants distance to hit position

vec_add(trace_vec, [trace start position]);



after this 'trace_vec' is the spawn position of your entity, 50 quants away from the hit position (at least in theory).

Last edited by Kartoffel; 09/01/12 17:03.

POTATO-MAN saves the day! - Random

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