Hi,
I just started using Stencyl and this is my first post.
tl;dr: skip to the Update below I am making a laser simulator with basic optics (at least the stuff that can be done with particle-based approximations). Right now my "laser" shoots only one photon upon a key press, just to keep things simple. I built a beam splitter actor. In real life these are typically placed 45 degrees relative to the beam and allow half the beam through and the other half reflects at 90 degrees relative to the original beam. In Stencyl, the reflection part is done automatically by the built-in physics engine and the transmission part can be faked by spawning a new photon actor with no collision box at the collision point and pushing it in the direction the original photon was moving upon collision.
Trouble is, the direction of "last collided Actor" isn't what I expected it to be. The photon travels straight up, hits the splitter, and reflects as it should. However, a print statement reveals that the "direction of last collided Actor" is not up but is rather 0,
regardless of the beam splitter's orientation.
What's going on here?
UPDATE: Apparently I got confused between the
direction of an actor (which way it is facing) and the
direction component of an actor's velocity (which direction it's moving in). The latter is what I need. How do I get it?
There does not seem to be a getter for this in the event block palettes, even though there is a setter for it. Can I get it with code? Can I create my own palettes so I can make this missing pallette?
UPDATE 2 See 2nd to last post on this thread:
http://community.stencyl.com/index.php/topic,4730.15.htmlThis is how to get the direction component of velocity. There really ought to be a simple "Get direction (velocity)" palette.
But now there is a new problem: The direction of last collided actor gives me the direction that the original photon reflects towards AFTER the collision, not its direction at the moment of the collision, which is what i expected to get. I want the latter. How do I do that?