Home   Help Search Login Register  

Author Topic: spawning objects  (Read 1057 times)

0 Members and 1 Guest are viewing this topic.

Offline AlexZ

  • Members
  • *
spawning objects
« on: 21 Apr 2009, 18:58:50 »
Hello,

I am trying to indicate a grid on the terrain, I thought for now I could indicate each point of the grid by spawning a small object like a traffic cone for example. So I guess this is a two part question, how do I spawn a structure/object in real time, and how do I get the height of the terrain for the objects z position.

Thank you.

Walter_E_Kurtz

  • Guest
Re: spawning objects
« Reply #1 on: 22 Apr 2009, 03:23:33 »
Use the createVehicle command.

You don't need a z dimension for objects that will be on the ground. Also note Spooner's comment: if the created object collides with another, the game engine will place it somewhere nearby.

Have a go with the following:
Start creating a new mission in the mission editor.
Place yourself as a soldier named dude.
Create a trigger, activated by Radio Alpha, repeatedly, and write the following in the On Activation line:
[] exec "barrel_square.sqs"

Code: (barrel_square.sqs) [Select]
_firstbarrel = "Barrel1" createVehicle [(getPos dude select 0) - 5, (getPos dude select 1) - 5]
_secondbarrel = "Barrel1" createVehicle [(getPos dude select 0) - 5, (getPos dude select 1) + 5]
_thirdbarrel = "Barrel1" createVehicle [(getPos dude select 0) + 5, (getPos dude select 1) - 5]
_fourthbarrel = "Barrel1" createVehicle [(getPos dude select 0) + 5, (getPos dude select 1) + 5]

exit

Preview the mission. Every time you call Radio Alpha, you will find yourself in the centre of a ten-metre square marked by barrels.


P.S. Are you sure this is related to OFP, because I don't quite understand your other question? Are the two topics somehow related?

Offline AlexZ

  • Members
  • *
Re: spawning objects
« Reply #2 on: 22 Apr 2009, 17:53:28 »
Thank you very much for the solution. This is actually for VBS2, but those forums are not as active as the mod community forums, I thought I would try my luck here.

I will update my other post to clarify the question.

Thanks,

Alex