Rotating brushmodel

Have questions about CoD4 mapping that aren't covered in the tutorials section? Post here!

Moderator: Core Staff

Post Reply
User avatar
j_head
CJ Wannabe
CJ Wannabe
Posts: 19
Joined: February 8th, 2013, 11:14 pm

Rotating brushmodel

Post by j_head » July 10th, 2015, 10:55 pm

How do i rotate Two objects in Two directions at the same time?

/cg_rotate object a_to direction b_.gsc

This code doesn't work
Last edited by j_head on July 13th, 2015, 11:40 pm, edited 1 time in total.

User avatar
Xpayne
PC Team
PC Team
Posts: 1751
Joined: May 13th, 2008, 8:17 am
Location: Estonia

Re: Rotating brushmodel

Post by Xpayne » July 10th, 2015, 11:01 pm

Rotating brushes:
1. Make the brushes into the object you want to rotate.

2. On the axis that you want to rotate around, make a small brush of 8x8 or 16x16 and texture it with the origin texture from the tools textures.

3. Select all the brushes that are to be rotated and select the origin brush.

4. With the brushes and origin selected, right click on the 2D screen and select script>brushmodel.

5. With the brushes and origin still selected, press N to bring up the Entity window and enter the following key/value entries.

Targetname/rotate
Script_noteworthy/x,y or z for the desired axis
Speed/ the number of seconds for object to make one revolution

------------------

Rotating models:
1. Place the model you wish to rotate. Models do not need an origin brush, and will rotate around their own origin.

2. With the model selected, right click the 2D screen and select script>model.

3. With the model still selected, press N and set the speed desired and script_noteworthy for the rotation axis. Press Esc and that finishes the radiant work for a model.

NOTE: prefabs can’t be rotated and this includes prefab models. If you want to rotate a vehicle for example, you would need to place the model and set it to rotate as shown above. Open the vehicle prefab and copy the clips to your map. Add an origin to the clips to match your model axis, and set it to rotate as a script_brushmodel as shown above. With the model and clips rotating in the same position on the same axis, at the same speed, they are still two separate entities, but in game will function as one.

The Script

main()
{
rotate_obj = getentarray("rotate","targetname");
if(isdefined(rotate_obj))
{
for(i=0;i<rotate_obj.size;i++)
{
rotate_obj thread ra_rotate();
}
}
}

ra_rotate()
{
if (!isdefined(self.speed))
self.speed = 10;
if (!isdefined(self.script_noteworthy))
self.script_noteworthy = "z";

while(true)
{
// rotateYaw(float rot, float time, <float acceleration_time>, <float deceleration_time>);
if (self.script_noteworthy == "z")
self rotateYaw(360,self.speed);
else if (self.script_noteworthy == "x")
self rotateRoll(360,self.speed);
else if (self.script_noteworthy == "y")
self rotatePitch(360,self.speed);
wait ((self.speed)-0.1); // removes the slight hesitation that waittill("rotatedone"); gives.
// self waittill("rotatedone");
}
}







The first part of the script collects all the entities with the target name of rotate. The second part checks the entity for speed, if none specified, it will be 10 as indicated in the script. This number can be changed. The last section checks the axis the entity is to rotate around. If no script noteworthy is specified, the Z axis will be assigned.

Files

The above script goes in its own gsc called mp_mymapname_rotate.gsc and goes in the rawmapsmp folder like the main gsc.

Add the line: mapsmpmp_mymapname_rotate::main(); to the main gsc

Add the line: rawfile,maps/mp/mp_mymapname_rotate.gsc to the missing asset csv (step 4 of compile tools)

This completes the script and files. Recompile the map from step 1 of the compile tools and enjoy!!!!
I'll take care of checking whether the music is royalty-free or not

Let's save this post.

Image

Uploaded with ImageShack.us

Post Reply

Who is online

Users browsing this forum: No registered users and 5 guests