Gamestudio Links
Zorro Links
Newest Posts
MT5 bridge not working on MT5 v. 5 build 4160
by EternallyCurious. 04/25/24 20:49
Data from CSV not parsed correctly
by EternallyCurious. 04/25/24 10:20
Trading Journey
by howardR. 04/24/24 20:04
M1 Oversampling
by Petra. 04/24/24 10:34
Zorro FIX plugin - Experimental
by flink. 04/21/24 07:12
Scripts not found
by juergen_wue. 04/20/24 18:51
zorro 64bit command line support
by 7th_zorro. 04/20/24 10:06
StartWeek not working as it should
by jcl. 04/20/24 08:38
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
4 registered members (EternallyCurious, AndrewAMD, TipmyPip, Quad), 889 guests, and 8 spiders.
Key: Admin, Global Mod, Mod
Newest Members
Mega_Rod, EternallyCurious, howardR, 11honza11, ccorrea
19048 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Vec_for_vertex --- problem with temp.x #471325
02/28/18 05:23
02/28/18 05:23
Joined: Feb 2005
Posts: 67
USA
June Offline OP
Junior Member
June  Offline OP
Junior Member

Joined: Feb 2005
Posts: 67
USA
Hello,

I'm adding a muzzle flash model to be created when the gun fires. The flash is supposed to come from a specified vertex which I believe is in the code correctly.

Here is the code:

vec_for_vertex (temp.x, plyr_machinegun, 32);

ent_create (mflash_mgun_mdl, temp.x, muzzle_flash);


However, when I run the engine, there is this error message:

'temp' undeclared identifier
< vec_for_vertex (temp.x, plyr_machinegun, 32); >


Can anyone see what is causing the problem?


June
smooth-3d.com
Re: Vec_for_vertex --- problem with temp.x [Re: June] #471327
02/28/18 05:41
02/28/18 05:41
Joined: Feb 2003
Posts: 146
RP China
2
20BN Offline
Member
20BN  Offline
Member
2

Joined: Feb 2003
Posts: 146
RP China
replace temp to other.

VECTOR* vec_your_set;
or in void
VECTOR vec_your_set;

Re: Vec_for_vertex --- problem with temp.x [Re: 20BN] #471349
02/28/18 17:15
02/28/18 17:15
Joined: Feb 2005
Posts: 67
USA
June Offline OP
Junior Member
June  Offline OP
Junior Member

Joined: Feb 2005
Posts: 67
USA
A simple solution, thank you 20BN.

I believe temp.x worked in .wdl code but not in lite-c.


June
smooth-3d.com
Re: Vec_for_vertex --- problem with temp.x [Re: June] #471355
02/28/18 18:56
02/28/18 18:56
Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
Superku Offline
Senior Expert
Superku  Offline
Senior Expert

Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
The reason is that temp was a predefined VECTOR in wdl but not in lite-C.
Just write
VECTOR temp; // don't make it a pointer (VECTOR*)
at the start of your script, in your function or directly before the commands and it will work.

Btw. the ".x" suffix is superfluous on VECTORs.


"Falls das Resultat nicht einfach nur dermassen gut aussieht, sollten Sie nochmal von vorn anfangen..." - Manual

Check out my new game: Pogostuck: Rage With Your Friends
Re: Vec_for_vertex --- problem with temp.x [Re: Superku] #471360
03/01/18 05:43
03/01/18 05:43
Joined: Feb 2005
Posts: 67
USA
June Offline OP
Junior Member
June  Offline OP
Junior Member

Joined: Feb 2005
Posts: 67
USA
Thank you for the tips Superku.

Do you know if its possible to use vec_for_vertex on a ent_createlayer entity?

I've been trying for many hours to figure it out.

Basically the first person weapon is created at the start of the game using ent_createlayer.

When the gun is firing the intention is to create a muzzle flash at the vertex # of the tip of the gun. For some reason it is not appearing when the gun fires (bullets are surely coming out though).

The code in the gun firing function:

VECTOR mgun_tip;

vec_for_vertex(mgun_tip, plyr_machinegun, 32);

ent_create (mgun_flash_mdl, mgun_tip, muzzle_flash);

function muzzle_flash()
{
set (my, PASSABLE);
set (my, TRANSLUCENT);
my.ambient = 100;
my.roll = random(360);
my.scale_x = 5.4;
my.scale_y = my.scale_x;
wait (-0.25);
ent_remove (my);
}


June
smooth-3d.com
Re: Vec_for_vertex --- problem with temp.x [Re: Superku] #471364
03/01/18 08:54
03/01/18 08:54
Joined: Feb 2005
Posts: 67
USA
June Offline OP
Junior Member
June  Offline OP
Junior Member

Joined: Feb 2005
Posts: 67
USA
Something I can't seem to figure out from the manual:

Can you use vec_for_vertex on a view entity?


June
smooth-3d.com
Re: Vec_for_vertex --- problem with temp.x [Re: June] #471365
03/01/18 09:35
03/01/18 09:35
Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
Superku Offline
Senior Expert
Superku  Offline
Senior Expert

Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
Well the gun is in the camera's own coordinate system and vec_for_vertex would probably return the wrong result either way.
Just find it our yourself what it returns:
- Have the camera at 0-pos and 0-pan. Have your gun at 0-(view-)pos as well. Call vec_for_vertex on your gun and note the result (compare with MED).
- Put the gun at the right position and repeat.
- Moving and rotating the camera should return the same result.
- If so, use vec_rotate(temp,camera.pan) and vec_add(temp,camera.x) to get the world position.


"Falls das Resultat nicht einfach nur dermassen gut aussieht, sollten Sie nochmal von vorn anfangen..." - Manual

Check out my new game: Pogostuck: Rage With Your Friends
Re: Vec_for_vertex --- problem with temp.x [Re: Superku] #471372
03/01/18 17:36
03/01/18 17:36
Joined: Feb 2005
Posts: 67
USA
June Offline OP
Junior Member
June  Offline OP
Junior Member

Joined: Feb 2005
Posts: 67
USA
I see, the vector needs to be converted to a world position. I will play around with it, thank you Superku.


June
smooth-3d.com
Re: Vec_for_vertex --- problem with temp.x [Re: June] #471391
03/02/18 17:18
03/02/18 17:18
Joined: Feb 2005
Posts: 67
USA
June Offline OP
Junior Member
June  Offline OP
Junior Member

Joined: Feb 2005
Posts: 67
USA
Your advice worked perfectly.


June
smooth-3d.com
Re: Vec_for_vertex --- problem with temp.x [Re: June] #471396
03/02/18 17:39
03/02/18 17:39
Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
Superku Offline
Senior Expert
Superku  Offline
Senior Expert

Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
Very well.


"Falls das Resultat nicht einfach nur dermassen gut aussieht, sollten Sie nochmal von vorn anfangen..." - Manual

Check out my new game: Pogostuck: Rage With Your Friends

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