edited August 17 in ORK Support
Hi!
What would be the best way to create this feature:

The player should be able to move certain objects directly (lets say an apple) in the game world by clicking on it, then choosing in a context menu either "pick up" or "move" - when he chooses move he should be able to point the mouse where he wants to move it to and the object should drop there. (eg, apple is on table, player clicks on it, chooses move and then moves the mouse on the floor beside the table and the apple drops there if he clicks again).
Post edited by Corvyn on
  • edited August 13
    In your event, just add in all the nodes in the picture.
    https://www.dropbox.com/s/vrsth3jbcdmxlbd/dfdfgdafd fd fd af dafd.PNG?dl=0

    In the raycast node, just set a variable name in the VARIABLE KEY. Enable Use Input and enable USE CLICK. All the way down in the ray origin, choose either USER or SCREEN, and edit the rest of the setting to fit your game.

    In the change position node, put in EVENT OBJECT(which should be created in the setting node). In the Position Value Type, put in GAME VARIABLE. In the VARIABLE KEY, put in the variable that you created in the raycast node.

    Attach the event to the apple.
    Post edited by Shadow_Fire on
  • Thanks! It works! Do you think it would be possible to have the object (the apple) at the mouse (move with the mouse) until the player clicks to drop it?
  • edited August 14
    Sure, it's very easy to do too.
    https://www.dropbox.com/s/75amk9r9q1j1rq4/dfdgrtrg fgb.PNG?dl=0

    This time, in the raycast node, disable the USE INPUT. Go all the way down to the LAYER MASK, click the EVERYTHING so that a list will pop out and tick off IGNORE RAYCAST.

    For the success slot, connect it to the change position node. After that, add a WAIT FOR INPUT node and put in the mouse 0 as the input key(which should be created in the BASE CONTROL -> INPUT setting). Enable WAIT with a wait time of 0.

    In the input key fail slot, drag it back to the raycast node. For the success slot, copy the change position node and connect the success to it.

    Lastly, in the apple game object's layer, put in IGNORE LAYER. Or if you already got a layer for the apple, in the raycast node, choose that layer instead.

    Oh yeah, in the raycast fail slot, drag it back to itself if you dont want the event to stop completely if it fail( if you point to the sky and the raycast is too short)
    Post edited by Shadow_Fire on
  • You are awesome!! it works.
    Sorry, but now I got another question :) The object when I drag it around is on the ground, or on another object if I move the mouse there, which is good BUT it's kinda half way in the ground and so it can happen that it falls through and it simply doesn't look good. Any idea how I could constantly have it hover a bit higher?
    I tried to change the Y value in the Raycast To Variable node (all the way down in the Raycast settings) but it doesn't seem to do anything.
  • I don't think Ork can do that. With Makinom, it could, but I'm still trying to figure out how to do it in there. When the raycast hit a point, you need to figure out how to offset the position of the apple in the opposite direction of the hit point. After GiL get back from his break, hopefully he can shine a light on this issue.
  • Ok, thank you again for taking the time to help me out!
  • Can you check to see it ifs grabbing it's center point or its pivot point?
    If it's a pivot point you could theoretically just alter its pivot in blender.
    Warborn
  • edited August 15
    Yeah that is also one method, Wrofir. Corfvyn, if you go this route, an addition after you alter the pivot point in blender is to also get the normal of the raycast and use it in the quaternion.FromToRotation method to always rotate the apple so that the apple can rotate to match the surface of the hit mesh.
    In script it is easy to do, but I don't know if there is the FromToRotation method in ork or makinom.
    Post edited by Shadow_Fire on
  • Thanks for the idea (it looks like it's the pivot point), but I'd like to have a solution within ORK (or Makinom) because I'd use this on many objects.
    I kinda remember GIL giving someone tips about how to place objects at the mouse cursor for some strategy game feature - so it should be possible. I hope he has some input to this when he is back.
    The object being too low into the ground is an issue with both version (object constantly at mouse position and also the instant move at click Shadow Fire showed me first). The chance of the object falling through the ground at the time it's being placed is too high at the moment.
  • I found a solution for the falling through world issue - actually 2 solutions :)

    Solution 1.) I just add a "Move into Direction" node after the "change position" which comes after the mouse click. In the move into direction node I move the event object 1 to Y. so it jumps a bit up. Important is to disable the rotation in the rigidbody so Y is always actually up.

    Solution 2.)
    Add to the Y value of the Variable which is set by "Raycast to Variable" node. Just add a "Change game variable" node after that node and change your variable value to Y 0.3. This way it always adds 0.3 to the Y value of the value set by the raycast and this way it keeps it above ground! (also make sure to disable rotation in the rigidbody).
Sign In or Register to comment.