Author Topic: Change CurvedTunnel, CurvedFrequency, CurvedAmplitudes at runtime  (Read 90 times)

saverdrome

  • Newbie
  • *
  • Posts: 2
    • View Profile
hi guys,

i m using your fantastic asset in my game and i have tried to set curved properties at runtime (also instantiating the tunnel gameObject from code) but what happens is that the tunnel completely loses the initial position once curved tunnel switches from off to on.

you can find attached the result when i create the tunnel from code (but the same identical result comes out if i add the gameobject into the scene from IDE) and the i run the code

tunnel = TunnelFX2.CreateTunnel(new Vector3(0, 0, 0));
TunnelFX2 tunnelEffect = tunnel.GetComponent<TunnelFX2>();
tunnelEffect.preset = TunnelEffect.TUNNEL_PRESET.SpaceTravel;
tunnelEffect.curvedTunnel = true;

and the result (second image attached) if i comment out the set of curvedTunnel (no issue at all)

tunnel = TunnelFX2.CreateTunnel(new Vector3(0, 0, 0));
TunnelFX2 tunnelEffect = tunnel.GetComponent<TunnelFX2>();
tunnelEffect.preset = TunnelEffect.TUNNEL_PRESET.SpaceTravel;
//tunnelEffect.curvedTunnel = true;

am i missing something?

« Last Edit: October 03, 2020, 10:01:18 PM by saverdrome »

Kronnect

  • Administrator
  • Hero Member
  • *****
  • Posts: 6214
    • View Profile
Re: Change CurvedTunnel, CurvedFrequency, CurvedAmplitudes at runtime
« Reply #1 on: October 04, 2020, 04:15:53 PM »
Hi,

There're a couple of additional properties that need to be set when switching to curved mode, which are: positionAnimated = false, and segments = 200 (so resulting tunnel is a flexible tube of concatenated rings).
These settings are automatically set by the editor inspector behind the scenes when you click the curved mode, but were not being set when using scripting.
However this is fixed now in latest version which you can now download from the beta board.

Regards

saverdrome

  • Newbie
  • *
  • Posts: 2
    • View Profile
Re: Change CurvedTunnel, CurvedFrequency, CurvedAmplitudes at runtime
« Reply #2 on: October 04, 2020, 06:19:03 PM »
hi,

thank you for the response and the super fast build update!
« Last Edit: October 04, 2020, 06:21:07 PM by saverdrome »