[PLUGIN]Math-update 9/11(additional features)

This forum is currently in read-only mode.
  • new additions 9-10-11

    hi guys, big update. For those of you who could just never get the whole moving things with lerp thing, of for those who get sick of typing in the events. Math now has actions to autointerpolate over time. there are two different ways.

    first is to create a value to interpolate, that you can retrieve from expressions.

    The second is to interpolate object positions,rotations,and dimensions automatically over a given time. like being able to order an object to a location. there are also triggered conditions for when interpolation completes, and actions to pause and resume interpolation. using the automated interpolated value actions and expressions, you could automate anything like pv's, opacity, and color.

    also, the interpolation allows you to set a speed curve control point anything from 0 to 1, 0 is ease in, 0.5 is linear, and 1 is ease out.

    hope it comes in handy, have fun!!!

    new additions 9-11-11

    • added the ability to set the current value, of interpolated values, which will create the value if it doesn't exist.
    • you can now access values like this: math.yourvaluename and you have not yet created the value, it will return 0
    • if you do it like this: math.yourvaluename(somedefaultvalue) and you have not yet created the value, it will return your default value
    • added the ability to change the total time for the interpolation on the fly, as well as the time elapsed, and interpolation curve control point

    special thanks to FrenchYann and Somebody for suggestions and testing

    (latest update (9-11-11   10:30am:additional bug fixes)

    this will be an evergrowing plugin of math functions:

    http://dl.dropbox.com/u/1013446/sharinplugs/math/plugins.rar

    AngleLerp(a,b,t)

    is like lerp(a,b,t) for angles

    basically you can lerp two angles, between 0 and 360 (EDIT:no longer has the limitation of having to be angles between 0 and 360), and not have to worry about crossing the 0/360 line just lerp and be happy, knowing that everything is taken care of, and your brainchildren are safe

    the second one is Get T which is simply typed t

    it's for helping with lerp functions, it's the opposite of lerp

    if lerp is x==lerp(a,b,t)

    then t==t(a,b,x)

    in simpler terms, t(a,b,x) will give a value between 0 and 1 that represents how far between a and b x is.

    I'll give more detailed examples later, but this one should suffice for people who already understand lerp and can do this without the t function: say you're looping between 2 and 6 and you want to set create a sprite between point a and b that starts at a and ends at b as you go through the loop evenly spaced in between you would just do

    lerp(a,b,t(2,6,loopindex))

    hidden functions:

    the intersectx, and intersecty expressions

    they aren't on the expression list, but they work

    example cap here:

    http://dl.dropbox.com/u/1013446/New%20folder%20%286%29/New%20folder/intersection.cap

    these give you the point at which two lines intersect

    you can do this 4 ways

    specify 4 xy coordinates:

    ntersectx(x1,y1,x2,y2,x3,y3,x4,y4)

    intersecty(x1,y1,x2,y2,x3,y3,x4,y4)

    specify 3 xy coordinates(the first two form a line, the 3rd is assumed to be on a perpendicular line):

    ntersectx(x1,y1,x2,y2,x3,y3)

    intersecty(x1,y1,x2,y2,x3,y3)

    specify 4 objects

    ntersectx("object1name","object2name","object3name","object4name")

    intersecty("object1name","object2name","object3name","object4name")

    specify 3 objects (the first two form a line, the 3rd is assumed to be on a perpendicular line):

    ntersectx("object1name","object2name","object3name")

    intersecty("object1name","object2name","object3name")

    all 4 methods are available in the example cap, just toggle them on and off

  • Beats my clamp method.;(

  • derp i need to try this

  • Does not work for me. It keeps saying AngleLerp is not a recognised system expression

  • If you didn't click on the object to get the expression in the event editor, you will need to reference the object like so: math.anglelerp(a,b,t)

  • Thank you, works like a charm now.

  • k, latest addition is the intersectx, and intersecty expressions

    they aren't on the expression list, but they work

    http://dl.dropbox.com/u/1013446/New%20f ... r/math.rar

    example cap here:

    http://dl.dropbox.com/u/1013446/New%20f ... ection.cap

    these give you the point at which two lines intersect

    you can do this 4 ways

    specify 4 xy coordinates:

    [quote:25zqgnkk]intersectx(x1,y1,x2,y2,x3,y3,x4,y4)

    intersecty(x1,y1,x2,y2,x3,y3,x4,y4)

    specify 3 xy coordinates(the first two form a line, the 3rd is assumed to be on a perpendicular line):

    [quote:25zqgnkk]intersectx(x1,y1,x2,y2,x3,y3)

    intersecty(x1,y1,x2,y2,x3,y3)

    specify 4 objects

    [quote:25zqgnkk]intersectx("object1name","object2name","object3name","object4name")

    intersecty("object1name","object2name","object3name","object4name")

    specify 3 objects (the first two form a line, the 3rd is assumed to be on a perpendicular line):

    [quote:25zqgnkk]intersectx("object1name","object2name","object3name")

    intersecty("object1name","object2name","object3name")

    all 4 methods are available in the example cap, just toggle them on and off

  • Wow. That is so cool, it hurts my head just thinking of it's potential. Awesome, man.

  • Question regarding (plugin)math.

    Can i use this plugin to display the 'Yaw' angle of 3d object.(with text object)

    If the player holds down the left mouse the object rotates(yaw) to the left.

    If he holds down right mouse, the object rotates(yaw) to the right.

    i tried the following -

    Set text to int(abs(math.AngleLerp(0, 360, BaseB.Yaw)))

    and,

    Set text to int(math.AngleLerp(0, 360, BaseB.Yaw))

    and,

    Set text to int(abs(math.AngleLerp(BaseB.Yaw, BaseB.Yaw, BaseB.Yaw)))

    Can't get it to work?

    Also, could i have the number reset to 0 if the model turns full circle.

    thanks in advance.

  • I thought yaw didn't reset when you got to 360.

  • I thought yaw didn't reset when you got to 360.

    The main problem is getting a value between 0 and 360, without the minus. The setting it to zero option was an after-thought. I can't work out how to do anything with the plugin at the minute.

  • <font ="Apple-style-span" color="#0000ff">Solved it, without the plugun.</font><div>

    </div><div><div>+ System: Start of layout</div><div>-> yawmaths: Set 'yaw' to 0</div><div>

    </div><div>+ MouseKeyboard: Key Left mouse button is down</div><div>-> yawmaths: Subtract 1 from 'yaw'</div><div>

    </div><div>+ MouseKeyboard: Key Middle mouse button is down</div><div>-> BaseA: Set roll to BaseA.Roll-2 degrees</div><div>-> TopB: Set yaw to TopB.Yaw-1 degrees</div><div>

    </div><div><font ="Apple-style-span" color="#0000ff">+ yawmaths: Value 'yaw' Equal to -1</font></div><div><font ="Apple-style-span" color="#0000ff">-> yawmaths: Set 'yaw' to 360</font></div><div>

    </div><div><font ="Apple-style-span" color="#0000ff">+ yawmaths: Value 'yaw' Equal to 361</font></div><div><font ="Apple-style-span" color="#0000ff">-> yawmaths: Set 'yaw' to 0</font></div><div>+ System: Always (every tick)</div><div>-> yawmaths: Set text int(yawmaths.Value('yaw'))</div><div>

    </div><div>

    </div></div>

  • <div id="swiffout"></div>sorry for the late reply brobs, but I think you might have misinterpreted the point of the anglelerp feature

    normally if you lerp two angles like

    lerp(245,15,0.5), instead of going from 245 up to 15 crossing the 360/0 boundary, it would go backward down to 15

    this let's you lerp the shortest route of 2 angles even if it jumps the 360/0 boundary.

    now that it's solved I won't go back and figure out what you were trying to do in greater detail, unless you'd like me to

    in which case...I will

  • Hi lucid, I have suggestion about new expression, I think it will be very handy.

    Something like usual lerp, but with persistent speed. Like lerp\cosp it will have starting value, goal value and change speed rate. I know I can compare values to determine in wich side move from starting value, but to have it all in one expression will better.

    (Sorry if I missed something like that already exists)

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • that's a good idea dtrq

    I was planning to add math actions as well

    hadn't thought of that one in particular

    probably not anytime soon, but shouldn't be too difficult

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)