0 registered members (),
1,459
guests, and 9
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
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
SomebodyNew
OP
Newbie
|
OP
Newbie
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):
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
Junior Member
|
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]
#281624
07/27/09 21:00
07/27/09 21:00
|
Joined: Jul 2009
Posts: 36
SomebodyNew
OP
Newbie
|
OP
Newbie
Joined: Jul 2009
Posts: 36
|
Hey Storm_Mortis, thanks for helping me out. My initial function looked like this:
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.
|
|
|
Moderated by mk_1, Perro, rayp, Realspawn, Rei_Ayanami, rvL_eXile, Spirit, Superku, Tobias, TSG_Torsten, VeT
|