playMaker

Author Topic: How to calculate logarithm or how to linear zoom?  (Read 1547 times)

JochemB

  • Playmaker Newbie
  • *
  • Posts: 3
How to calculate logarithm or how to linear zoom?
« on: March 04, 2018, 01:27:31 PM »
Dear list, for a project I'm working on I have a linear zoom in on several game objects. I accomplished this first in script, but now I decided to make it all work in Playmaker. I am fairly new to Playmaker, and I can't find the right actions, not even in Ecosystem, so I'm think that I overlook something here.

What I did in script:

(1) I  calculated the logarithm of my begin and end values, then (2) I tweened between them and afterwards (3) I calculated the inverse of the chosen logarithm to determine the instantaneous linear scale.


Code: [Select]
// 1
startValLog = Mathf.Log10 (Mathf.Abs(startVal));
endValLog = Mathf.Log10 (Mathf.Abs(endVal));

// 2
iTween.ValueTo (gameObject, iTween.Hash ("from", startValLog, "to", endValLog, "speed", speed, "LoopType", "loop", "easetype", "linear", "onupdate", "computeValue"));

// 3
public void computeValue(float i){

i = Mathf.Pow (10f, i);
transform.localPosition = new Vector3 (0f, 0f,i);
}

Can somebody point me in the right direction how to add this Log10 before my Ease Vector3 and reverse it afterwards? Do you use an action I'm overlooking? Would it be useful to add this ease type in the Ease Vector3 action?
Many thanks!


djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7616
    • jinxtergames
Re: How to calculate logarithm or how to linear zoom?
« Reply #1 on: March 04, 2018, 06:56:49 PM »
Hi,
For part 1 you can use the 'Float Abs' action.

And part 3 you can get the action "FloatOperatorAdvanced" from the Ecosystem

JochemB

  • Playmaker Newbie
  • *
  • Posts: 3
Re: How to calculate logarithm or how to linear zoom?
« Reply #2 on: March 06, 2018, 08:07:04 AM »
Ah, yes, I see it now, many thanks. And I just discovered how to make custom actions which makes it all even better. Although I need to get back to drawing board for my project because I stumble across some other problems. Anyway, a good opportunity to discover Playmaker. Thanks again!

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7616
    • jinxtergames
Re: How to calculate logarithm or how to linear zoom?
« Reply #3 on: March 06, 2018, 05:52:24 PM »
Hi,
If you need help making actions let me know.