Gamestudio Links
Zorro Links
Newest Posts
Newbie Questions
by fairtrader. 12/05/23 14:22
Zorro Trader GPT
by TipmyPip. 12/04/23 11:34
Square root rule
by Smallz. 12/02/23 09:15
RTest not found error
by TipmyPip. 12/01/23 21:43
neural function for Python to [Train]
by TipmyPip. 12/01/23 14:47
Xor Memory Problem.
by TipmyPip. 11/28/23 14:23
Training with command line parameters
by TipmyPip. 11/26/23 08:42
Combine USD & BTC Pairs In Asset Loop
by TipmyPip. 11/26/23 08:30
AUM Magazine
Latest Screens
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Tactics of World War I
Who's Online Now
3 registered members (TedMar, AndrewAMD, fairtrader), 578 guests, and 0 spiders.
Key: Admin, Global Mod, Mod
Newest Members
fairtrader, hus, Vurtis, Harry5, KelvinC
19019 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 1 of 3 1 2 3
problem with target... #121252
04/03/07 19:52
04/03/07 19:52
Joined: Feb 2006
Posts: 2,185
mpdeveloper_B Offline OP
Expert
mpdeveloper_B  Offline OP
Expert

Joined: Feb 2006
Posts: 2,185
i'm re writing a code where i need an entity that is spawned by the player to turn to a target position which is found by a line that traces from the camera to an (almost) infinate line in front of it. i'll post both parts:

Code:

vec_set(temp,vector(9999999,0,0)); //Set temp to an almost infinate quant long line
vec_rotate(temp,camera.pan); //Rotate line by camera
//vec_add(temp,my.x); //commented for th moment
res = c_trace (camera.x, temp.x, ignore_me + ignore_you + ignore_passable + ignore_sprites);



to keep you updated, the pointers are as following:
me = the entity
you = the player

Code:

vec_set (temp2, target.x);
vec_sub (temp2, my.x);
vec_to_angle (my.pan, temp2); // turn the me towards you



this is where the problem seems to lie, i can't get the entity to turn to the target position...why?

this problem didn't occur till updating from 6.3 to 6.5

Last edited by Manslayer101; 04/03/07 20:07.

- aka Manslayer101
Re: problem with target... [Re: mpdeveloper_B] #121253
04/03/07 22:11
04/03/07 22:11
Joined: Mar 2006
Posts: 2,503
SC, United States
xXxGuitar511 Offline
Expert
xXxGuitar511  Offline
Expert

Joined: Mar 2006
Posts: 2,503
SC, United States
*sigh* - I know your tired of hearin htis from me, so I'm not even going to say it

I'll try to explain though...


If the point you are tracing to is directly ahead, and you want to face directly ahead, then your already facing the target.

No matter how far away the collision is, it's still directly ahead of the camera.


Please tell me if I'm missing something...


xXxGuitar511
- Programmer
Re: problem with target... [Re: xXxGuitar511] #121254
04/04/07 06:50
04/04/07 06:50
Joined: Mar 2006
Posts: 3,538
WA, Australia
J
JibbSmart Offline
Expert
JibbSmart  Offline
Expert
J

Joined: Mar 2006
Posts: 3,538
WA, Australia
from what i can see, xXxGuitar511 is right. except, with "vec_add(temp,my.x);" i don't see what you are going to achieve, but it usually won't be right in front of the camera. maybe that's what you want.

also, vars only have a range of +/- 999999.999, but you are trying to use 9999999. that's one too many digits. that could be a problem, maybe it won't be and the engine will handle that.

julz


Formerly known as JulzMighty.
I made KarBOOM!
Re: problem with target... [Re: JibbSmart] #121255
04/04/07 20:31
04/04/07 20:31
Joined: Feb 2006
Posts: 2,185
mpdeveloper_B Offline OP
Expert
mpdeveloper_B  Offline OP
Expert

Joined: Feb 2006
Posts: 2,185
@ guitar: no, that would be true if the entity was created in the middle of the screen, it would arrive in the correct place, but it's not, what i want is for the entity (bullet) to go to the direct spot that is being hit, the bullet is being created at the player's arm, or chaingun, this results in the entity landing in the wrong spot, but only since updating, when i had 6.3 then the bullet arrived in the correct spot in the 3d world

@ Julz: you may be correct, it worked before, but that may be the problem

if i have to i will make a sketch of what i need

Last edited by Manslayer101; 04/04/07 20:33.

- aka Manslayer101
Re: problem with target... [Re: mpdeveloper_B] #121256
04/04/07 21:19
04/04/07 21:19
Joined: Mar 2006
Posts: 2,503
SC, United States
xXxGuitar511 Offline
Expert
xXxGuitar511  Offline
Expert

Joined: Mar 2006
Posts: 2,503
SC, United States
Ok, I understand now. Sorry I didn't realize this in the first place. The problem is the my pointer. Your using the bullets position, not the camera's...


Just replace the my.x with camera.x (third line, commented out).


xXxGuitar511
- Programmer
Re: problem with target... [Re: xXxGuitar511] #121257
04/05/07 07:33
04/05/07 07:33
Joined: Mar 2006
Posts: 3,538
WA, Australia
J
JibbSmart Offline
Expert
JibbSmart  Offline
Expert
J

Joined: Mar 2006
Posts: 3,538
WA, Australia
ah yes, i see now too! i assumed the my entity was in the camera's position, or some other excuse like that

julz


Formerly known as JulzMighty.
I made KarBOOM!
Re: problem with target... [Re: JibbSmart] #121258
04/05/07 14:45
04/05/07 14:45
Joined: Feb 2006
Posts: 2,185
mpdeveloper_B Offline OP
Expert
mpdeveloper_B  Offline OP
Expert

Joined: Feb 2006
Posts: 2,185
heh, actually my was the bullet, thanks again guys, if you're not already written down for the credits, u just got added


- aka Manslayer101
Re: problem with target... [Re: mpdeveloper_B] #121259
04/19/07 15:02
04/19/07 15:02
Joined: Feb 2006
Posts: 2,185
mpdeveloper_B Offline OP
Expert
mpdeveloper_B  Offline OP
Expert

Joined: Feb 2006
Posts: 2,185
well....it didn't work, i'm not sure why, i don't know why it's failing
Code:

function turn_towards_target()
{
vec_set(temp,vector(9999999,0,0)); //Set temp to a 2000 quant long line
vec_rotate(temp,camera.pan); //Rotate line by camera
vec_add(temp,camera.x); //Align temp with the camera
trace_mode = ignore_me + ignore_you + ignore_passable + ignore_sprites; //Or whatever you want
result = trace(camera.x,temp.x); //Trace between them, may want to use c_trace
if(result == 0) //Nothing was traced
{
vec_sub(temp,my.x); //Take my pos out of the trace-to location
vec_to_angle(my.pan,temp); //Point towards it
}
else
{
vec_set(temp,target.x); //Get the traced location
vec_sub(temp,my.x); //Take my pos out of the equation
vec_to_angle(my.pan,temp); //Point towards it
}
}



i edited the line as asked, the player is blocked in so the trace should be hitting walls

Last edited by Manslayer101; 04/19/07 15:09.

- aka Manslayer101
Re: problem with target... [Re: mpdeveloper_B] #121260
04/19/07 15:39
04/19/07 15:39
Joined: Mar 2007
Posts: 776
Poor village - Poland ;)
tompo Offline
User
tompo  Offline
User

Joined: Mar 2007
Posts: 776
Poor village - Poland ;)
I'm not sure what you want to do?
Trace line between camera and far point front of camera.
And if nothing hit whith trace put end of this line very far, but if hit something then put end of line on the hited target?

Last edited by tompo; 04/19/07 15:39.

Never say never.
Re: problem with target... [Re: tompo] #121261
04/19/07 15:56
04/19/07 15:56
Joined: Mar 2006
Posts: 2,503
SC, United States
xXxGuitar511 Offline
Expert
xXxGuitar511  Offline
Expert

Joined: Mar 2006
Posts: 2,503
SC, United States
Code:

function turn_towards_target()
{
vec_set(temp, vector(10000,0,0));
vec_rotate(temp, camera.pan);
vec_add(temp, camera.x);
trace_mode = ignore_me + ignore_you + ignore_passable + ignore_sprites;
result = c_trace(camera.x, temp.x, trace_mode);
if (result)
{vec_set(temp, target.x);}
vec_sub(temp, my.x);
vec_to_angle(my.pan, temp);
}



There are no problems with this code. The bullet will hit whatever is in the center of the camera's view. What does the bullets code look like?


xXxGuitar511
- Programmer
Page 1 of 3 1 2 3

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