Object rotation

  • #30, by afrlmeTuesday, 22. September 2015, 16:17 9 years ago
    I tried to add / subtract from the current rotation value in an earlier version of the script & it did not seem to work out too well for whatever reason. I found the best approach was to create a table containing the degrees I wanted to cycle through.

    Radians is actually a lot more complicated than degrees. Radians works based on the value for Pi (p). I think it's something like Pi x2 for a full rotation or something. It's a lot harder to calculate than simply converting degrees to radians with the math.rad() function or vice versa with the math.deg() function.

    I do recommend using the if degree for each key = 0 then puzzle = solved method as it is the simplest method.

    In regards to your values being up to 270. It doesn't really matter as it should reset back to degree 0 anyway. 360 is degree 0. I noticed when you reach 0 it rotates in reverse back to 0 instead of round back to 0, which is why I suggested setting the delay to 0. I know it might look nice with the smooth rotation transition, but the player still has to wait for that each time as would the engine when it comes to querying the rotation value of each key.

    Imperator

    7278 Posts


  • #31, by PaupasiaTuesday, 22. September 2015, 16:41 9 years ago
    Sorry I haven't saw your correction about my script with rad grin
    What do you think about this command written by Simons?

    Objects.object.Rotation = 1.5

    Could be helpful for me? Otherwise I'll follow your instructions.

    Forum Fan

    165 Posts

  • #32, by afrlmeTuesday, 22. September 2015, 19:06 9 years ago
    I believe Simon said it was a value of 2 to make it rotate 360 degrees. It's a decimal value, but not as accurate as degrees. Give it a try & see what you think?

    What Simon means by Objects.object.Rotation is...

    Objects["test"].Rotation or Objects.test.Rotation, where test is the name of the object itself. I recommend using the ["square_bracket"] method though.

    Imperator

    7278 Posts

  • #33, by PaupasiaTuesday, 22. September 2015, 19:15 9 years ago
    Thank you so much, I was looking in internet, tutorial, examples in Lua and so on, in search of a solution but seems no one has my problem ahah

    Forum Fan

    165 Posts

  • #34, by afrlmeTuesday, 22. September 2015, 19:17 9 years ago
    Finding stuff for Lua can be pretty difficult as most engines / apps incorporate Lua in different ways. Lua is usually used to expand on an existing sytem / object based system.

    Imperator

    7278 Posts

  • #35, by PaupasiaWednesday, 23. September 2015, 00:02 9 years ago
    Yep! I've seen grin

    Forum Fan

    165 Posts

  • #36, by tristan-kangWednesday, 23. September 2015, 00:54 9 years ago
    Damn it. What I've been doing... Why I had to do all struggle to rotate image and make animations of it...

    Just with this function... I... Damn it.

    At least I only have two scenes yet. This is really useful function.

    Great Poster

    267 Posts

  • #37, by afrlmeWednesday, 23. September 2015, 01:02 9 years ago
    Rotation of an object / animation via tweening is only useful if what you are wanting to rotate is flat to the screen. You have to think in terms of 2D. An image or animation that has a skewed perspective for example would only be rotate-able in true 3D. In that case it could be done by creating the object in a 3D program & adding it as a character to the 3D character section, then you would be able to control the camera perspective via Lua script I believe. This is of course pure theory as I've not actually messed with the 3D side of VS, nor do I have much intentions of doing so.

    P.S: depending on what you are rotating via normal animation (frames), it can sometimes be broken down into a few frames. Something such as a cog or a ball or even a windmill could be rotated with anything up to 10 frames easily providing the image is symmetrical all way round.

    Imperator

    7278 Posts

  • #38, by tristan-kangWednesday, 23. September 2015, 01:09 9 years ago
    Don't worry about it. The images are completely flat. I drew 1/4 of the image and paste it to 4/4. Then the art(?) has made. Mostly it is just gears, propellers, stuffs like that. Of course, it's has square border. Asymmetry isn't art...

    Besides, my game doesn't need to consider various camera angle. Because it's full 2D.

    Great Poster

    267 Posts

  • #39, by afrlmeWednesday, 23. September 2015, 01:51 9 years ago
    Don't worry about it. The images are completely flat. I drew 1/4 of the image and paste it to 4/4. Then the art(?) has made. Mostly it is just gears, propellers, stuffs like that. Of course, it's has square border. Asymmetry isn't art...

    Besides, my game doesn't need to consider various camera angle. Because it's full 2D.


    Was meant more as a tip / note about alternative possibilities of rotation in VS.

    My point about not needing many frames for actual rotation for a flat object such as a gear, windmill or propeller is that you only need to animate the turn between one gear tooth or propeller blade movement, then you just loop back to the first frame. The only way this is not possible is if the image contains unique texture or things draped on top of or attached to it. Maybe you have a windmill & it has flora growing on parts of it.

    Imperator

    7278 Posts

  • #40, by tristan-kangWednesday, 23. September 2015, 02:08 9 years ago

    Was meant more as a tip / note about alternative possibilities of rotation in VS.

    My point about not needing many frames for actual rotation for a flat object such as a gear, windmill or propeller is that you only need to animate the turn between one gear tooth or propeller blade movement, then you just loop back to the first frame. The only way this is not possible is if the image contains unique texture or things draped on top of or attached to it. Maybe you have a windmill & it has flora growing on parts of it.


    Objects["Propellers1_bedroom"]:to(1500, {Rotation = math.rad(360)}, easeLinearInOut, true, false)
    Objects["Propellers2_bedroom"]:to(1500, {Rotation = math.rad(360)}, easeLinearInOut, true, false)
    Objects["Gears1_bedroom"]:to(3000, {Rotation = math.rad(360)}, easeLinearInOut, true, false)
    Objects["Gears2_bedroom"]:to(3000, {Rotation = math.rad(360)}, easeLinearInOut, true, false)
    Objects["Gears3_bedroom"]:to(3000, {Rotation = math.rad(360)}, easeLinearInOut, true, false)
    Objects["Gears4_bedroom"]:to(3000, {Rotation = math.rad(360)}, easeLinearInOut, true, false)
    Objects["Gears5_bedroom"]:to(1500, {Rotation = math.rad(360)}, easeLinearInOut, true, false)
    Objects["Gears6_bedroom"]:to(1500, {Rotation = math.rad(360)}, easeLinearInOut, true, false)
    


    There are current objects I've made. Before I use this script, I made around 10 frames for one object (image) before, like I located every image 36 degree. Of course I didn't need to put final image because final image is first image. Now after...

    I don't know what you saying, it just works too perfectly from my view and I can save tons of resources to make a game smaller. And the image locates full frame (this is important) and it is too smooth no matter how image is complicated. I can show you the video how I made it anyway if you request.

    Seems like there is hidden bug that I don't know... you're scaring me. lol

    I can't turn back what I have done to around 40 frames for images...

    Great Poster

    267 Posts