Gamestudio Links
Zorro Links
Newest Posts
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
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
4 registered members (degenerate_762, AbrahamR, AndrewAMD, ozgur), 667 guests, and 8 spiders.
Key: Admin, Global Mod, Mod
Newest Members
Hanky27, firatv, wandaluciaia, Mega_Rod, EternallyCurious
19051 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
rel. distances... vector(my.x, my.y, my.z) #281544
07/27/09 17:06
07/27/09 17:06
Joined: Jul 2009
Posts: 36
S
SomebodyNew Offline OP
Newbie
SomebodyNew  Offline OP
Newbie
S

Joined: Jul 2009
Posts: 36
Hello everyone,
I wrote a script that lets the player fly an aircraft and shoot two missiles simultaneously from under its wings.
The script creates two "missile"-entities on the my.x, my.y etc coordinates +/- something (so that the missiles are created at the left and right ends of the aircrafts wings).

Now my first try looked like this (i left out all the unrelated code for a better overview):
Code:
function missiles()
{
	ent_create("missile.mdl", vector(plAIR.x + 50,plAIR.y + 50,0), rocket);
	ent_create("missile.mdl", vector(plAIR.x - 50,plAIR.y + 50,0), rocket);
	wait(1);
}


The problem was that the two missiles where always created using axis-coordinates +/- 50 quants (absolut coordinates). So my question is if there is a way to use relative coordinates where 0,0,0 is the entities position?
(the problem is not the angle of the missiles, thats already done - they're always shot in the direction the player is facing).

I've been able to go around that problem using some awfull long formulas (sin/cos plus each entity's individual collision model). I'm sure however that lite-c offers a better way to do this. I've looked in the manual but have not found anything there.

Thanks for your time.

Re: rel. distances... vector(my.x, my.y, my.z) [Re: SomebodyNew] #281607
07/27/09 20:20
07/27/09 20:20
Joined: Sep 2006
Posts: 99
BS, Germany
Storm_Mortis Offline
Junior Member
Storm_Mortis  Offline
Junior Member

Joined: Sep 2006
Posts: 99
BS, Germany
you need to use a sinus calculation.
this shoulnt be this awfulf long ....

this may be wrong but, this should it look - just have a look at the manual to fix that:

function missiles()
{
ent_create("missile.mdl", vector(plAIR.x + 50 * sin(plAIR.pan),plAIR.y + 50 * sin(plAIR.pan,0), rocket);
ent_create("missile.mdl", vector(plAIR.x - 50 * sin(plAIR.pan,plAIR.y + 50 * sin(plAIR.pan,0), rocket);
wait(1);
}


if you spoke of this, im sorry but i dont know how to do this but using vertex coords(vec_for_vertex...)


it found a voice ... now it needs a body
Re: rel. distances... vector(my.x, my.y, my.z) [Re: Storm_Mortis] #281622
07/27/09 20:54
07/27/09 20:54
Joined: Dec 2008
Posts: 605
47°19'02.40" N 8°32'54.67" E...
hopfel Offline
User
hopfel  Offline
User

Joined: Dec 2008
Posts: 605
47°19'02.40" N 8°32'54.67" E...
There's a typo:

ent_create("missile.mdl", vector(plAIR.x - 50 * sin(plAIR.pan -->)<-- ,plAIR.y + 50 * sin(plAIR.pan,0), rocket);

wink


Hilf mir, dir zu helfen!
Re: rel. distances... vector(my.x, my.y, my.z) [Re: Storm_Mortis] #281624
07/27/09 21:00
07/27/09 21:00
Joined: Jul 2009
Posts: 36
S
SomebodyNew Offline OP
Newbie
SomebodyNew  Offline OP
Newbie
S

Joined: Jul 2009
Posts: 36
Hey Storm_Mortis,
thanks for helping me out.
My initial function looked like this:
Code:
function missiles()
{
	ent_create("missile.mdl", vector(plSHIP.x+50*[color:#FF0000]+[/color]sin(plSHIP.pan), plAIR.y+50*cos(plAIR.pan), 0), rocket);
	ent_create("missile.mdl", vector(plAIR.x+50*[color:#FF0000]-[/color]sin(plAIR.pan), plAIR.y+50*-cos(plAIR.pan),0), rocket);
	wait(1);
}



I had those two mixed up... so these two missile launchers were rotating a bit wired. Only matching the Aircrafts rotation every 90°.
Then I made up some really long formulas... I feel so stupid now... a simple "-" and "+" mix up...

Thanks for showing me. That saved me quiet some time.

P.S.: The tutorial (chapter 8, at the end) states that a negative pan rotates the model counterclockwise and a positive pan rotates a model clockwise. It the other way around, isn't it?
If you create an entity and rotate it by positive 30 degrees it rotates counterclockwise (mathematical correct).
Well, just a detail.

Problem solved, thanks again.

Last edited by SomebodyNew; 07/27/09 21:01.

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