Gamestudio Links
Zorro Links
Newest Posts
Executing Trades on Next Bar Open
by vicknick. 06/13/24 08:51
Zorro Beta 2.61: PyTorch
by jcl. 06/10/24 14:42
New FXCM FIX Plugin
by flink. 06/04/24 07:30
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
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
1 registered members (henrybane), 1,246 guests, and 8 spiders.
Key: Admin, Global Mod, Mod
Newest Members
AemStones, LucasJoshua, Baklazhan, Hanky27, firatv
19059 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
ent_create #415492
01/19/13 15:41
01/19/13 15:41
Joined: Dec 2008
Posts: 83
Buenos Aires, Argentina
F
Funeral Offline OP
Junior Member
Funeral  Offline OP
Junior Member
F

Joined: Dec 2008
Posts: 83
Buenos Aires, Argentina
i need to create an entity that act exactly like the player, to follow it, rotates along it, etc... and it has to be always behind the player even if the player faces in a different direction.

Re: ent_create [Re: Funeral] #415493
01/19/13 15:48
01/19/13 15:48
Joined: Jul 2001
Posts: 4,801
netherlands
Realspawn Offline

Expert
Realspawn  Offline

Expert

Joined: Jul 2001
Posts: 4,801
netherlands
Did you so a search in forum ? resourche ? aum's ?

if so then you missed this one :

[codefunction player_follower();
action players_code() // attach this action to your player model
{
var movement_speed = 20;
VECTOR temp;
set (my, INVISIBLE);
player = my;
ent_create("guard.mdl", nullvector, player_follower);
while (1)
{
my.pan -= 7 * mouse_force.x * time_step;
vec_set (temp.x, my.x);
temp.z -= 10000;
temp.z = 0;
temp.x = movement_speed * (key_w - key_s) * time_step;
temp.y = movement_speed * (key_a - key_d) * 0.6 * time_step;
c_move (my, temp.x, nullvector, IGNORE_PASSABLE | GLIDE);
camera.x = my.x;
camera.y = my.y;
camera.z = my.z + 50;
camera.pan = my.pan;
camera.tilt += 5 * mouse_force.y * time_step;
wait (1);
}
}
function player_follower()
{
var walk_percentage;
while (1)
{
// play with the numerical values; they give the xyz offset of the follower in relation with the player
vec_set(my.x, vector(150, -60, 0));
vec_rotate(my.x, you.pan);
vec_add(my.x, you.x);
my.pan = you.pan;
ent_animate(my, "walk", walk_percentage, ANM_CYCLE); // play the "stand" aka idle animation
walk_percentage += 5 * (key_w - key_s) * time_step; // increase walk_percentage only if the player is moving
wait (1);
}
}
][/code]]


From here you have to study this code make changes and
make it do what you really want wink

good luck laugh


Find all my tutorials & Workshops at : www.rp-interactive.nl

Creativity starts in the brain
Re: ent_create [Re: Funeral] #415494
01/19/13 15:48
01/19/13 15:48
Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
Superku Offline
Senior Expert
Superku  Offline
Senior Expert

Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
Use vec_set, vec_rotate, vec_add for the position (negative x-distance, rotate by player pan), then vec_set for the angles, ent_animate the entity the same way (if you have complex animations) or use the frame and next_frame parameters to copy simple animations.


"Falls das Resultat nicht einfach nur dermassen gut aussieht, sollten Sie nochmal von vorn anfangen..." - Manual

Check out my new game: Pogostuck: Rage With Your Friends
Re: ent_create [Re: Funeral] #415498
01/19/13 16:09
01/19/13 16:09
Joined: Dec 2008
Posts: 83
Buenos Aires, Argentina
F
Funeral Offline OP
Junior Member
Funeral  Offline OP
Junior Member
F

Joined: Dec 2008
Posts: 83
Buenos Aires, Argentina
this is my code, but the entity doesnt follow the player when it walks, and it doesnt always creates behind, if the player faces in the opositive diction the entity created ahead.

ent_create("newentity.mdl",nullvector,entity);


function entity()
{
while (my)
{
vec_set(my.x, vector(0, -4, 3));
vec_rotate(my.x, player.pan);
vec_add(my.x, player.x);
my.pan = player.pan;
wait (-1);
ent_remove(my);
}
}


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