Hello,

I'm a non-coder having some success with Makinom, but struggling with raycasts and selected data (I don't quite get it). I read the tutorials, but there was not enough there to help me understand. Could a Makinom guru walk me through using a raycast from an object to spawn a prefab at the hitpoint of the ray against a collider, and print the name of the object hit, and coordinates of the hitpoint? I can get a raycast to come out of the end of a pistol, and trigger a tagged machine on a unity cube with a box collider (I can print "object hit" to the unity console when an object is hit through a tagged machine), but I can't figure out how to use selected data to spawn prefabs at the intersection point. I don't really understand selected data use. Like what is the difference between data key and variable key, and data origin and variable origin? And what do I put in the drop down to the right of the note-pad thing, when Makinom asks for a variable key and a data key? When do I put "value" in the drop down vs. "variable/selected data" or "game object"? I think I need a "for-dummies" type of explanation. Thanks to any who can help!
  • To spawn a prefab at the hit point, you'll need to first store the hit point in a Vector3 variable. The Raycast node has options for that (in the Store Into Variables settings):
    - select the Local variable origin (since you'll probably only use this in the running schematic)
    - enable Store Hit Point
    - define the variable key (e.g. hitPoint)
    - select the Set operator

    To spawn the prefab, use a Spawn Prefab node (e.g. connected to the Success slot of the Raycast node):
    - select the Prefab you're using (set up in the Settings node)
    - select the Position target type
    - select the Vector3 Variable Vector3 type
    - use the variable key you defined earlier (e.g. hitPoint)
    - select the Local variable origin

    I don't think it's currently possible to print the name of a selected data object in the console, though.
    Please consider rating/reviewing my products on the Asset Store (hopefully positively), as that helps tremendously with getting found.
    If you're enjoying my products, updates and support, please consider supporting me on patreon.com!
  • Thank you, your response helped me narrow down my problem. I think I had the raycast and spawn nodes correct the whole time. My issue I think is with passing the local variables stored by the raycast along to a tagged machine. When I do as you say, and spawn the prefab from the schematic that performs the raycast (attach the spawn node to the success slot of the raycast), the prefab spawns in the correct place. But because the raycast comes from a weapon-type object, and the spawned effect depends on the object hit (e.g. a piece of wood vs. an alien), I wanted to handle the prefab spawning from a different schematic attached to a tagged machine on the object hit by the raycast. I store the hit object and hit point in local variables in the raycast node, then--instead of attaching the spawn prefab node--I attach a "start tagged machine" node to the success slot of the raycast, which starts a tagged machine on the game object stored in the hitObject local variable. I enable "share local variables" on this node, believing that the tagged machine started by the raycast hit will gain the local variables hitObject and hitPoint that were determined by the raycast. In the tagged machine, I have the prefab set up and the spawn prefab node set to spawn at the hitPoint, using local variable as the source. The raycast does trigger the tagged machine, but the prefab spawns at 0,0,0 worldpace, and not at the expected intersect point. Any thoughts?
  • edited May 2017
    The hitObject is a selected data, not a variable, i.e. it's not shared when sharing variables with the tagged machine (and also not needed in your case, since the hitObject is the one running the tagged machine, i.e. it's the Machine Object in that schematic).

    The hitPoint should be shared with the tagged machine - make sure you're using the correct variable key and origin in both schematics.
    Post edited by gamingislove on
    Please consider rating/reviewing my products on the Asset Store (hopefully positively), as that helps tremendously with getting found.
    If you're enjoying my products, updates and support, please consider supporting me on patreon.com!
Sign In or Register to comment.