Gamestudio Links
Zorro Links
Newest Posts
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
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
2 registered members (Akow, SBGuy), 1,423 guests, and 7 spiders.
Key: Admin, Global Mod, Mod
Newest Members
AemStones, LucasJoshua, Baklazhan, Hanky27, firatv
19058 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Move an entity towards point without rotating it to it #315084
03/13/10 10:19
03/13/10 10:19
Joined: Jul 2009
Posts: 96
M
mEnTaL Offline OP
Junior Member
mEnTaL  Offline OP
Junior Member
M

Joined: Jul 2009
Posts: 96
I want to move an entity towards another entity BUT not by the standard method with vec_diff(...) , vec_to_angle(...) and then c_move(...)
I want an ORIENTED sprite which can move in all directions BUT it is always rotated towards the camera
Help pls

Re: Move an entity towards point without rotating it to it [Re: mEnTaL] #315087
03/13/10 10:40
03/13/10 10:40
Joined: Sep 2003
Posts: 5,900
Bielefeld, Germany
Pappenheimer Offline
Senior Expert
Pappenheimer  Offline
Senior Expert

Joined: Sep 2003
Posts: 5,900
Bielefeld, Germany
It should work like the following. It is more pseudo code, I didn't test anything, it is just to give you an idea:

vec_diff(temp, me, you);//this is needed, but not the vec_to_angle
vec_lerp(temp, ...); //if you want the speed relating the distance to the target
vec_normalize(temp, ...);// if you want a steady speed, in this case you will have to combine it with vec_diff to avoid that it runs beyond the target and back, again and again.
c_move(NULLVECTOR, temp, ... );//the first vector is movement relating the entities orientation, the second uses the world's orientation, look into the manual to clarify this.

Re: Move an entity towards point without rotating it to it [Re: mEnTaL] #315088
03/13/10 10:43
03/13/10 10:43
Joined: Nov 2008
Posts: 354
saeculum II
MPQ Offline
Senior Member
MPQ  Offline
Senior Member

Joined: Nov 2008
Posts: 354
saeculum II
maybe sth. like this:

while(1)
{
c_move (sprite, ...)
vec_set (vecTemp, sprite.x);
vec_sub (vecTemp, camera.x);
vec_to_angle (sprite.pan, vecTemp);
wait(1);
}


new project in early stage...

Intel Xeon X3450 2,66GHz | Mushkin 8 Gib | Zotac GTS250 + 7300LE | A8.3 com
Re: Move an entity towards point without rotating it to it [Re: MPQ] #315115
03/13/10 12:23
03/13/10 12:23
Joined: Apr 2006
Posts: 624
DEEP 13
badapple Offline
User
badapple  Offline
User

Joined: Apr 2006
Posts: 624
DEEP 13
or you could attach it to an invisible low poly object that looks towards the target.

Re: Move an entity towards point without rotating it to it [Re: badapple] #315119
03/13/10 12:28
03/13/10 12:28
Joined: Aug 2007
Posts: 1,922
Schweiz
Widi Offline
Serious User
Widi  Offline
Serious User

Joined: Aug 2007
Posts: 1,922
Schweiz
Why attach to an other object? Then you have a function more in your code. One for the object to change the angle and another for attach the bitmap. Turn your bitmap directly, that saves resources (and at least fps).

Re: Move an entity towards point without rotating it to it [Re: Widi] #315122
03/13/10 12:35
03/13/10 12:35
Joined: Jul 2002
Posts: 4,436
Germany, Luebeck
Xarthor Offline
Expert
Xarthor  Offline
Expert

Joined: Jul 2002
Posts: 4,436
Germany, Luebeck
Code:
void move_WithoutTurn(ENTITY* _ent, ENTITY* _target, var _maxSpeed)
{
  VECTOR temp;
  vec_diff(temp,_target.x,_ent.x);
  if(vec_length(temp) > _maxSpeed)
  {
    vec_normalize(temp,_maxSpeed);
  }
  vec_scale(temp,time_step);
 
  c_move(_ent,nullvector,temp,IGNORE_PASSABLE);
}



just from the top of my head. The basic idea was already described by Pappenheimer.

Re: Move an entity towards point without rotating it to it [Re: Xarthor] #315317
03/14/10 18:15
03/14/10 18:15
Joined: Jul 2009
Posts: 96
M
mEnTaL Offline OP
Junior Member
mEnTaL  Offline OP
Junior Member
M

Joined: Jul 2009
Posts: 96
@Pappenheimer I tried your way, but maybe I haven't done it properly because nothing happens

@MPQ but with the c_move(...) the sprite will move in the relative direction which is towards the player

@badapple I've been thinking about this method, but I will use it if there is no other way

@Xarthor I tried it, there are no errors, but the sprite just stays on one place and don't move. Have you tested it? : (

Re: Move an entity towards point without rotating it to it [Re: mEnTaL] #315319
03/14/10 18:35
03/14/10 18:35
Joined: Sep 2009
Posts: 496
P
Progger Offline
Senior Member
Progger  Offline
Senior Member
P

Joined: Sep 2009
Posts: 496
here is a code of my football game

function attach_ba()
{

while(Ball==NULL){wait(1);}
while(1)
{

set(Ball,SHADOW);
proc_mode = PROC_LATE;
Ball.material = mat_metal;
Ball.x = player.x + 50 * cos(player.pan);
Ball.y = player.y + 50 * sin(player.pan);
Ball.z = player.z-41;
Ball.pan=player.pan;

Ball.tilt+=5 ;

wait(1);
}
}

WFG Progger


asking is the best Way to get help laugh laugh laugh
Re: Move an entity towards point without rotating it to it [Re: Progger] #315324
03/14/10 18:49
03/14/10 18:49
Joined: Jul 2009
Posts: 96
M
mEnTaL Offline OP
Junior Member
mEnTaL  Offline OP
Junior Member
M

Joined: Jul 2009
Posts: 96
@Progger maybe you didn't understand my question right. When i tested your code the sprite just stays always in front of the camera as if it's attached to it.

What I want is a sprite which must move towards an entity (for example ent_enemy) but it's always rotated towards the camera (oriented sprite)

Re: Move an entity towards point without rotating it to it [Re: mEnTaL] #315397
03/15/10 08:27
03/15/10 08:27
Joined: Jul 2002
Posts: 4,436
Germany, Luebeck
Xarthor Offline
Expert
Xarthor  Offline
Expert

Joined: Jul 2002
Posts: 4,436
Germany, Luebeck
I just tested my code and it works as it should.
You have to call that function in a while loop or put a while loop into the function itself.
Here is my testing set up as zip file (includes all sources):


and here is a modified function of the above one which moves the entity the whole way:
Code:
/*
 * move_WithoutTurn
 * This function moves one entity (_ent) towards another entity (_target) without
 * rotating the moving entity itself. The maximum movement speed is given through
 * _maxSpeed, the minimum distance until this code is executed is _minDist
 * requirements: both entity pointers have to be valid!
*/
void move_WithoutTurn(ENTITY* _ent, ENTITY* _target, var _maxSpeed, var _minDist)
{
	VECTOR temp;
	
 	while(vec_dist(_ent,_target) > _minDist)
  	{
  		vec_diff(temp,_target.x,_ent.x);
  		if(vec_length(temp) > _maxSpeed)
  		{
			vec_normalize(temp,_maxSpeed);
  		}
  		vec_scale(temp,time_step);
		
 		c_move(_ent,nullvector,temp,IGNORE_PASSABLE);
 		wait(1);
	}
}




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