ScriptSpot

Forum topic · General Scripting

rotation pivot problem

By titane357 · 2011-04-16

Description

Hello
I did a few lines of script for randomizing parked cars

"(
OBS = getCurrentSelection()
for OB in OBS do
(
a = #(0.0 , 180)
b = ( random 1 2)
--print OB as string
OBGZ = OB.rotation.z
NOBGZ = OBGZ + a[b]
OB.rotation.z = NOBGZ
)
)"

But the cars don't rotate around each car's pivot.
(I turned on "use pivot center" and "world")
Can somebody help ? Thanks :-)

Comments (6)

lol

Garp · 2011-04-18

You guys need to work more on your laziness.
Believe me, after a while you find ways to save a lot of keystrokes.

Or even...

Garp · 2011-04-18

for obj in selection do rotate obj (180 * random 0 1) z_axis

Less typing ;)

titane357 · 2011-04-18

yes... just one line ! brillant !
In fact I wanted to use an array :-)

br0t · 2011-04-18

Garp, did u ever play UT? *huuumiliatiooon* :D I got owned!
Very elegant one-liner

br0t · 2011-04-17

Hi,
I am sure there is some other way to fix this, but I still dont really understand those quaternion rotations ^^, so maybe this will work for you as well:


(
	OBS = getCurrentSelection()
	for OB in OBS do
	(
		a = #(0.0 , 180)
		b = ( random 1 2)
		rotate OB (eulerAngles 0 0 a[b])
	)
)

Cheers

titane357 · 2011-04-18

Thanks brOt, that's what I'm looking for :-)