[Mostly Solved] Using love.physic's setLinearVelocity to move towards a target following a cubic in eased curve
Posted: Sun Jan 01, 2017 8:33 pm
Messy title aside, I'm looking for a way to send a love.physics body from one specific position to another following an easeInCubic curve (http://easings.net/). I am using the flux tweening library.
I'm trying to get the physics objects to sync up to an image that I'm sending from point A (2300) to B (3400) using flux to emulate said curve, as shown below:
This is moving an image using the cubic in curve, and is working very nicely. However, I've spent the past few hours trying to emulate the same behavior using love.physics objects. Of course, :setX() (which works perfectly visually) does not allow collisions with other objects which is vital in my situation.
I cannot figure out what I could be doing to emulate the same behavior using setLinearVelocity (which is the only behavior I can use to allow proper collisions in my situation). I've toyed around with finding the percentage that the above flux-modified image has moved towards its goal and applying that to the linear velocity (which I assume is the correct approach), but I'm unable to find the correct values.
If it'll help, my current (and rather un-optimized/not fully working) code is here: http://pastebin.com/qeTfSM4G . If something should be defined, just let me know and I'll get back to you as soon as possible. (one notice, "movement" is not defined in the included paste)
Edit: Here's a gif of the situation. The white partial-box should be synced to the truck in the same position. The truck is an image, the boxes are a physics object which have the fill debug thing on: Thanks for reading, and I appreciate any help that can be offered!
I'm trying to get the physics objects to sync up to an image that I'm sending from point A (2300) to B (3400) using flux to emulate said curve, as shown below:
Code: Select all
flux.to(positionHoldingTable[currentObject], 12, {x = 3400}):ease("cubicin")
I cannot figure out what I could be doing to emulate the same behavior using setLinearVelocity (which is the only behavior I can use to allow proper collisions in my situation). I've toyed around with finding the percentage that the above flux-modified image has moved towards its goal and applying that to the linear velocity (which I assume is the correct approach), but I'm unable to find the correct values.
If it'll help, my current (and rather un-optimized/not fully working) code is here: http://pastebin.com/qeTfSM4G . If something should be defined, just let me know and I'll get back to you as soon as possible. (one notice, "movement" is not defined in the included paste)
Edit: Here's a gif of the situation. The white partial-box should be synced to the truck in the same position. The truck is an image, the boxes are a physics object which have the fill debug thing on: Thanks for reading, and I appreciate any help that can be offered!