Formulas that return vectors, or multiple values?

For developers using the Construct 2 Javascript SDK

Post » Mon Feb 09, 2015 10:31 am

Hi all, :)

Regarding ACEs, is there a best practice for implementing a formula that returns a vector?

I'm building a math plugin, and I was interested in adding an expression to return the intersection point between two lines.
To return a point, I need to return the X and Y value for that point.

The issue I'm running into is that C2 Expressions can't return vectors, and even if they could, there's no vector variable type in C2 to my knowledge, so there'd be nowhere to put the vector anyway. So I'm thinking I may have to use a combination of actions and expressions, to set parameters and retrieve the vector components individually.

Is there a good or standard way to do this?
Am I overlooking a way to do this purely with expressions?

It seems technically possible to make an expression that sets internal variables rather than returning a value, but I suspect using the execution of an expression to change the internal state of an object is not encouraged. :D
Posts: 322
Reputation: 6,017

Return to Javascript SDK

Who is online

Users browsing this forum: No registered users and 1 guest