Gamestudio Links
Zorro Links
Newest Posts
Blobsculptor tools and objects download here
by NeoDumont. 03/28/24 03:01
Issue with Multi-Core WFO Training
by aliswee. 03/24/24 20:20
Why Zorro supports up to 72 cores?
by Edgar_Herrera. 03/23/24 21:41
Zorro Trader GPT
by TipmyPip. 03/06/24 09:27
VSCode instead of SED
by 3run. 03/01/24 19:06
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
5 registered members (Nymphodora, AndrewAMD, TipmyPip, Quad, Imhotep), 847 guests, and 4 spiders.
Key: Admin, Global Mod, Mod
Newest Members
sakolin, rajesh7827, juergen_wue, NITRO_FOREVER, jack0roses
19043 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
how can I do this? #292841
10/07/09 12:38
10/07/09 12:38
Joined: Sep 2009
Posts: 84
Theil Offline OP
Junior Member
Theil  Offline OP
Junior Member

Joined: Sep 2009
Posts: 84
I want to move an entity toward a specific point without changing the pan of the entity is this possible?, I want to do this because when let's say an enemy attack the player he should move backward while playing he's hurt animation. this is what I have.

On the enemy's code I set this vector so it stays in front of the enemy, some kind marker where the player should move when he's getting hurt:

marker.x = enemy.x + 500 * cos(enemy.pan);
marker.y = enemy.y + 500 * sin(enemy.pan);

On the player's event I have this so when the touches the player he starts moving toward the marker:

vec_set(temp, marker.x);
vec_sub(temp, player.x);
vec_set(temp2, marker.y);
vec_sub(temp2, player.y);
player.x += temp*1*time_step;
player.y += temp2*1*time_step;

The problem with this is that collision won't work.

The other way I found is changing the entity's pan but I don't want to use this because it looks lame:

vec_set(temp, marker.x);
vec_sub(temp,player.x);
vec_to_angle(player.pan, temp);
c_move (player, vector(10 * time_step, 0, 0), nullvector, IGNORE_PASSABLE | GLIDE);



Last edited by Theil; 10/07/09 22:29.
Re: how can I do this? [Re: Theil] #292847
10/07/09 14:32
10/07/09 14:32
Joined: Aug 2007
Posts: 1,922
Schweiz
Widi Offline
Serious User
Widi  Offline
Serious User

Joined: Aug 2007
Posts: 1,922
Schweiz
If you want to move without changing the pan,
so you DON`T need:

vec_set();
vec_sub();
vec_to_angle();

This 3 things are only to change the pan. To move the entity you have to use c_move(); if you want the collision. If you set player.x directly, there is no collision.

Use only the following line:
c_move (player, vector(10 * time_step, 0, 0), nullvector, IGNORE_PASSABLE | GLIDE);

Hope that helps....


Last edited by Widi; 10/07/09 14:33.
Re: how can I do this? [Re: Widi] #292862
10/07/09 15:23
10/07/09 15:23
Joined: Sep 2009
Posts: 84
Theil Offline OP
Junior Member
Theil  Offline OP
Junior Member

Joined: Sep 2009
Posts: 84
Thanks for the quick reply laugh
well I've tried that and the only problem with that is that if the player is facing the enemy works just fine but if he's not facing the enemy it won't work since it goes backward and collides with the enemy =/

Re: how can I do this? [Re: Theil] #292878
10/07/09 17:48
10/07/09 17:48
Joined: Oct 2004
Posts: 1,655
T
testDummy Offline
Serious User
testDummy  Offline
Serious User
T

Joined: Oct 2004
Posts: 1,655
Code:
/* sample only: non-functional */
ENTITY* eSrc;
ENTITY* eTarget;
//...
VECTOR vSrc;
VECTOR vTarget;
VECTOR vDir;
//...
vec_set(vSrc, eSrc.x);
vec_set(vTarget, eTarget.x);

// ...
// drop the z of both VECTORs
vSrc[2] = 0;
vTarget[2] = 0;
vec_diff(vDir, vTarget, vSrc); // subtract the src from the target and store it in dir
vec_normalize(vDir, 1);	// normalize it
vec_scale(vDir, time_step); // scale it like a distance
// apply it to the ENTITY which should move towards vTarget / eTarget's pos
c_move(eSrc, NULLVECTOR, vDir, IGNORE_PASSABLE | GLIDE);



Re: how can I do this? [Re: testDummy] #292938
10/07/09 22:29
10/07/09 22:29
Joined: Sep 2009
Posts: 84
Theil Offline OP
Junior Member
Theil  Offline OP
Junior Member

Joined: Sep 2009
Posts: 84
Wow it works like a charm shocked
Thank you very much that was so quick :), awesome.


Moderated by  HeelX, Spirit 

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