Object rotation

  • #20, by afrlmeMonday, 18. May 2015, 16:33 9 years ago
    Yes you can easing for a lot of situations. You might want to move an object or animation to a new position in a scene & with easing you could have it gradually speed up or slow down or both. Or you could add bounce or elastic easing to an interface to have it bounce up & down when it slides out. There's loads of possibilities.

    P.S: Simon linked that easing webpage via the wiki I think. As for adventure fans... I don't actually post there. I think Thomas directly tied vs database into the adventure fans forum, so it does have its own unique content, but it also automatically takes threads from certain sections of the VS forum.

    P.P.S: there is probably more potential with VS than most people realize, which is one of the main reasons I tend to prefer approaching things with Lua script as it gives me access to features not yet implemented as action parts inside of the editor as well as access to openGL shader & the ability to write my own custom functions. With that in mind it's possible to create other game genres that VS was not meant for.

    Imperator

    7278 Posts


  • #21, by LebosteinMonday, 18. May 2015, 16:37 9 years ago
    If there are official and easy accessible tutorial examples to show that potential, Visionaire could get more users, I think. The problem of Visionaire is the missing professional presentation/promotion of the product... but I repeat myself

    Key Killer

    621 Posts

  • #22, by afrlmeMonday, 18. May 2015, 16:50 9 years ago
    Indeed. & unfortunately I'll repeat myself also... Currently I'm swamped with other things. Hmm I don't see anything in the wiki about the to() function. I thought it might have been added to the scripting page or the player functions, but it's a fairly recent addition to VS & has only really been working properly since 4.2.

    Imperator

    7278 Posts

  • #23, by PaupasiaTuesday, 22. September 2015, 02:39 9 years ago
    Hi, after short time... is time for me to use Lua... and I'm making a puzzle with this great template shared by AFRLme and Unreal, thank you so much for your great effort and help!
    Of course, since I'm a noob with Lua, I'm stuck with a command that I think is surely easy, but not for me shock
    I have three objects and I would like to check when every object is on a determinate degree. I've tried to change, for example, the check degree from 0 to 270, but don't works. Only works checking the degrees=0.
    I've managed to create a simple example of what I want to achieve and I can upload it.
    Could you help me please?

    Forum Fan

    165 Posts

  • #24, by afrlmeTuesday, 22. September 2015, 11:34 9 years ago
    Could you share your ved / script? I'm not really sure what the issue is based on what you have written. I can tell you however that the degrees are not 100% accurate because the engine actually uses radians instead of degrees which is why I added additional queries with the math.ceil &math.floor for rounding up the values to the closest lowest & highest integer number.

    Imperator

    7278 Posts

  • #25, by PaupasiaTuesday, 22. September 2015, 12:41 9 years ago
    Of course, thanks a lot AFRLme.
    From what you say, maybe this is my problem, and I can use radians instead of degrees for this puzzle.
    Well, Is the original puzzle of my game and I've put a simple solution in the if query to show you what I mean. But in order to make it work, there are too much query for me. If I can get the rad. position of each object by setting a value where the location is ok, will be easier to set a combination sequence and the visibility of every single lock.

    P.S. Forgot the solution! 1231 smile


    Forum Fan

    165 Posts

  • #26, by afrlmeTuesday, 22. September 2015, 13:58 9 years ago
    Ok so let me just break down your puzzle so that I have a better understanding of it...

    It's similar to the generic rotation tile puzzles except in this case we have 4 keys but only 3 are required for the puzzle. What is the key surrounded by the lights supposed to be for? I assume it would be supposed to be used if all lights are on to complete the puzzle? I recommend adding a locked clicking sound to be played when lights are off & have it rotate slightly then back to default position & only have it rotate into actual position when all lights are on. Or is it supposed to reset the key positions?

    I see that when I rotate one key it rotates the others.

    Finally as far as I can tell the aim of the mini-game is to get the 4 lock pins to detract from the box edges.

    In regards to your if queries... can you not just copy & edit the queries I added to the main script that control the rotation for checking the current degree value? That way you don't need all those other if queries & conditions.

    The lines I was talking about were these...
      if math.floor(math.deg(obj.Rotation)) == 0 or math.ceil(math.deg(obj.Rotation)) == 0 then obj:to(500, {Rotation = math.rad(90)}, easeLinearOut)
       elseif math.floor(math.deg(obj.Rotation)) == 90 or math.ceil(math.deg(obj.Rotation)) == 90 then obj:to(500, {Rotation = math.rad(180)}, easeLinearOut)
       elseif math.floor(math.deg(obj.Rotation)) == 180 or math.ceil(math.deg(obj.Rotation)) == 180 then obj:to(500, {Rotation = math.rad(270)}, easeLinearOut)
       elseif math.floor(math.deg(obj.Rotation)) == 270 or math.ceil(math.deg(obj.Rotation)) == 270 then obj:to(500, {Rotation = math.rad(0)}, easeLinearOut)
      end
    

    ... except you split each one into it's own if query. So you check if game.CurrentScene.SceneObjects["name"].Rotation == ... You get the idea.

    Imperator

    7278 Posts

  • #27, by PaupasiaTuesday, 22. September 2015, 15:10 9 years ago
    Thanks so much for your patience AFRLme.
    The key surrounded by lights moves every rotation of the other 3 keys, no matter what, and is required to solve the puzzle. Because this key should have only three sequentially moves from position 0 to position 270 (each light turns on each rotation). If you go over the 3 moves, the key is reset.
    But you need to open three locks and simultaneously have the fourth key, three moves in sequence.
    I mean that you can rotate other keys all you want, but the endgame should be in three sequential step for the fourth key.
    The keys reset when you reach the position 270 (this is why I haven't been able to set up a reverse rotation by 90 degrees, I tried setting ceil instead of floor, but as I said I'm a noob with Lua) and each key, sometimes, rotate another key just to add a bit of difficulty to the puzzle (but I think I've only added difficutly to my programming Ahahah).
    I will try your suggestion hoping to get something that works and sorry for my bad English grin

    Forum Fan

    165 Posts

  • #28, by afrlmeTuesday, 22. September 2015, 15:32 9 years ago
    Your English is perfectly fine & understandable. wink

    I think the hardest part of these puzzles is planning how they should work. Sometimes having it randomly rotate x tile / key (whatever) can cause issues - especially if you have them rotate in a way that they never all end up in the correct position.

    In regards to math.floor & math.ceil: these functions take decimal values (float) & round them up to integer values.

    * floor rounds down to the closest integer value. i.e: 3.71 to 3
    * ceil rounds up to the closest integer value. i.e: 3.71 to 4

    I also noted that you changed delay of all keys to 500 instead of using the actual delay variable. Personally I think it works best if you have them instantly snap between degree values.

    The simplest solution to the rotation puzzle is to manually create the images as you want them to be when solved (so that the final image would be for degree 0) then set the initial rotation value at the beginning of the puzzle to change them from degree 0 to whatever. All in all that means when all object degree values = 0, the puzzle is solved. Of course you could query if it equals x degree per object instead, but 0 is much simpler.

    Imperator

    7278 Posts

  • #29, by PaupasiaTuesday, 22. September 2015, 15:53 9 years ago
    My english fine? Eheh I'm flying now! grin
    I understand what you mean, but I love the smooth transition of the keys without made a single animation ahah
    So, maybe floor and ceil are not perfect for me and I should use rad?
    And yes, 0 is more simple but the solution need the keys in different position like, for example, 180, 90, 270 to link the locks images to them.(the example I made is not the final solution)
    I know my skill is not good for this kind of puzzle with Lua, maybe this will remain a beautiful dream Ahahah!
    To simplify my problem, there is a way to put a "execute a script" inside every key that turn +90 every left click till you reach 270? With this solution I can manage directly the values of the keys.

    Forum Fan

    165 Posts

  • #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