Trying to get the car turret to spin on its own

Place to get help with not working mods / modding interface.
Post Reply
robertpaulson
Long Handed Inserter
Long Handed Inserter
Posts: 92
Joined: Sun Jun 18, 2017 2:21 pm
Contact:

Trying to get the car turret to spin on its own

Post by robertpaulson »

I'm modding the vanilla car, and while my request is not my final intention it will beasically allow me to do what i want which is replace the car's turret with a beacon/radar animation that spins at all times.

So What I am trying to do is to get the vehicle turret to spin, with no enemies around. I just want it to spin around, through the frames.
I was trying to play with the vanilla code, changing "frame count" and "direction count" only rotated the turret when the car was moving (the faster it moved that faster it rotated) which is perfect but it wasn't working when the player was not in the car (remote controlled car). I would settle for either spinning all the time or doing w/e is doing now but without the player inside.... to be honest I am not sure why the animation speed is synchronized with the car speed.... Will anyone be nice enough to give me some tips or point me in the right direction?
Vanilla code for car turret below:

Code: Select all

car.turret_animation = {
        layers = {
          {
            animation_speed = 8,
            direction_count = 64,
            filename = "__custom-vehicles__/graphics/car/car-turret.png",
            frame_count = 1,
            height = 29,
            line_length = 8,
            shift = {
              0.03125,
              -0.890625
            },
            width = 36
          },
          {
            direction_count = 64,
            draw_as_shadow = true,
            filename = "__custom-vehicles__/graphics/car/car-turret-shadow.png",
            frame_count = 1,
            height = 31,
            line_length = 8,
            shift = {
              0.875,
              0.359375
            },
            width = 46
          }
        }
      }
car.turret_rotation_speed = 0.1

Kuldrtorix
Manual Inserter
Manual Inserter
Posts: 3
Joined: Fri Jun 16, 2017 7:27 pm
Contact:

Re: Trying to get the car turret to spin on its own

Post by Kuldrtorix »

I am not a modder or a very experienced scriptor, but what I believe is happening is the turret is running off of the car's driving animation. So when you are in the car and driving, the animation of the car is linked to how fast the car is going (slow moving = slow animation, and vice versa), and the turret spinning is using that animation speed for some reason. I probably have no clue what I am talking about.

robertpaulson
Long Handed Inserter
Long Handed Inserter
Posts: 92
Joined: Sun Jun 18, 2017 2:21 pm
Contact:

Re: Trying to get the car turret to spin on its own

Post by robertpaulson »

so a lil update, I haven't managed to get it spin around. But I managed to point at the player. There is a property of "orientation" that accepts angles, and with some utility library I managed to get the turret to player.position angle (util.vector_to_orientation_xy). However when I'm trying to iterate angle through small steps it doesn't seem to spin around. I guess the angle units are not degrees but rad or something else, but even then it should spin just faster/slower.... anyhow I will settle for a radar like animation that will point at the player (makes more sense since these RC cars are long range)

Post Reply

Return to “Modding help”