SetObjectRotation

Modders can post their questions on scripting and more.

Moderators: Slitherine Core, BA Moderators

Post Reply
enric
Brigadier-General - 8.8 cm Pak 43/41
Brigadier-General - 8.8 cm Pak 43/41
Posts: 1855
Joined: Sun May 15, 2011 8:47 am

SetObjectRotation

Post by enric »

id = PlaceObject(x, y, "Test", "pontoon_bridge_centre");

SetObjectRotation(id, 0);
or
SetObjectRotation(id, 90);
or
SetObjectRotation(id, 180);

Are not rotating according to the degree system, can you tell me which criteria should be followed to place objects in a precise direction?, or maybe I'm using the wrong functions.
pipfromslitherine
Site Admin
Site Admin
Posts: 9928
Joined: Wed Mar 23, 2005 10:35 pm

Re: SetObjectRotation

Post by pipfromslitherine »

As per the docs, the degrees are in 100ths, so you'll want to use 0, 9000, and 18000 in these examples. So they were indeed rotating already - just only by a max of 1.8 degrees :)

Cheers

Pip
enric
Brigadier-General - 8.8 cm Pak 43/41
Brigadier-General - 8.8 cm Pak 43/41
Posts: 1855
Joined: Sun May 15, 2011 8:47 am

Re: SetObjectRotation

Post by enric »

ummmm, look at the picture, bottom left, the Engineers have placed a pontoon facing 0.
SetObjectRotation(id, 0);

On top, the other engineers have placed the same object with 27000.
enric
Brigadier-General - 8.8 cm Pak 43/41
Brigadier-General - 8.8 cm Pak 43/41
Posts: 1855
Joined: Sun May 15, 2011 8:47 am

Re: SetObjectRotation

Post by enric »

ummmm, look at the picture, bottom left, the Engineers have placed a pontoon facing 0.
SetObjectRotation(id, 0);

On top, the other engineers have placed the same object with 27000.
Screen Shot 2012-10-20 at 18.57.29.jpg
Screen Shot 2012-10-20 at 18.57.29.jpg (71.78 KiB) Viewed 1369 times
enric
Brigadier-General - 8.8 cm Pak 43/41
Brigadier-General - 8.8 cm Pak 43/41
Posts: 1855
Joined: Sun May 15, 2011 8:47 am

Re: SetObjectRotation

Post by enric »

The only working numbers are 0 and 157.
0 are vertical tiles, and 157 horizontal, is there any logic here that I' missing ?.
Screen Shot 2012-10-20 at 20.36.10.jpg
Screen Shot 2012-10-20 at 20.36.10.jpg (150.28 KiB) Viewed 1366 times
pipfromslitherine
Site Admin
Site Admin
Posts: 9928
Joined: Wed Mar 23, 2005 10:35 pm

Re: SetObjectRotation

Post by pipfromslitherine »

Hmmm - I'm pretty sure I tested it when I wrote it. And I've not got the code in front of me right now. But on a hunch, try doing it in radians. That is, make the value you put into the function be:

value = (100 * degrees * PI)/180

If that works, then I forgot to do the conversion. If not, I'll have to double check it. I'm guessing it is used by the random mission mods, so I think it must work at least somewhat.

Cheers

Pip
enric
Brigadier-General - 8.8 cm Pak 43/41
Brigadier-General - 8.8 cm Pak 43/41
Posts: 1855
Joined: Sun May 15, 2011 8:47 am

Re: SetObjectRotation

Post by enric »

value = (100 * degrees * PI)/180
This formula gives 0 for 0 degrees and 157 for 90 degrees.
It's ok for me the 157 as I only want to place horizontal or vertical the object.
pipfromslitherine
Site Admin
Site Admin
Posts: 9928
Joined: Wed Mar 23, 2005 10:35 pm

Re: SetObjectRotation

Post by pipfromslitherine »

Yeah - that's what made me guess that that was the issue. I'll check and see whether I need to change either the code or the docs (I don't want to break any existing code when i make the fix)

Cheers

Pip
Post Reply

Return to “Battle Academy : Modders Corner ”