Jump to content
Sign in to follow this  
revv

Spawn object facing specific direction?

Recommended Posts

Hi I am having to spawn the new ATM's in via script/trigger since I could not find them in the editor as an object so now my issue is how do I get them facing a particular direction after spawning?

I am using a custom map which is why I need to do this. Also which method is best for adding something to the init field of the spawned object?

Here is what I have so far:

A trigger which runs the script at server startup and spawns the ATM

Activation: Anyone

Radius: 1x1

On Act: null = [] execVM "atm.sqf";

Script:

atm.sqf contains:

_atm1 = "Land_Atm_01_F" createVehicle (getMarkerPos "atm_new_1");

_atm1 = setDir (markerDir "atm_new_1");

I don't know if this is the proper way of doing it I have only dabbled in mission making a handful of times :)

Share this post


Link to post
Share on other sites

Ok after some more playing with this I found that this is working:

Trigger set to go from anyone not present and radius is 1x1 (still not sure if this is the best way to set it off)

On Act: null = [] execVM "atm.sqf"; (not sure if this is right for a dedi server but I guess I will find out soon)

the "atm.sqf" contains this:

atm1 = createVehicle ["Land_Atm_01_F", getMarkerPos "atm_new_1", [], 0, "CAN_COLLIDE"];

atm1 setDir (markerDir "atm_new_1");

I might say also that there is a marker called "atm_new_1" which I placed on the map.

There is more code in the sqf but that is to do with some other stuff irrelevant here.

So the new atm model BIS put in the game is now being spawned exactly where I place the marker and facing the same direction as the marker too.

This is all working now and just though I would post it here if anyone else has similar issues! (check the spoiler)

Share this post


Link to post
Share on other sites

Just came here about to post almost the same question.

I have a script for a player (s3) to spawn a static weapon

_mg1b = createVehicle ["B_HMG_01_high_F", getPos s3, [],1,"NONE"];

_mg1b setDir 180;

works fine but I would like to static to spawn in the direction the player (s3) is facing rather than the setDir. I tried removing the setDir but then anything spawned will always face north.

Thanks in advance

Share this post


Link to post
Share on other sites
_mg1b setDir (getDir s3);

I was going to say the same thing lol.

Also remember if you put CAN_COLLIDE in the last field it will ignore any other objects for exampl if you're trying to spawn it inside a bunker and it keeps spawning outside use CAN_COLLIDE and it will spawn EXACTLY where you tell it to.

Share this post


Link to post
Share on other sites

Revv for the trigger set the activation to anything and set condition to isserver, then it will only spawn once and not for each player on the server.

alternatively, just put the activation script into init.sqf as it will then run at start up as well, inside an

 if isserver then {//run script};

Edited by KevsnoTrev
tidied up code - posted from phone originally...

Share this post


Link to post
Share on other sites
Revv for the trigger set the activation to anything and set condition to isserver, then it will only spawn once and not for each player on the server.

alternatively, just put the activation script into init.sqf as it will then run at start up as well, inside and if isserver then {//run script};

Thanks mate! Im just waiting for my friend to get online he does all the server side stuff as it's beyond the scope of my coding abilities. I will try what you have suggested though :)

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×