Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
FollowSpline Speed Question
#1
Hey... We were talking on Unity's forum and I am moving that thread here to your support forum Curvy thread.

I currently have a custom script which is called during an "[font]OnTriggerEnter", that detects when my character running along the spline collides with a sphere collider.  I have created dynamic sphere colliders which are used as waypoints on my path.  As soon as my character collides with a waypoint sphere collider, I want to dynamically change the speed of my character.

My character is using your "Follow Spline" script (with the updateAbsolutePrecise function) which moves it along the spline path, and I am looking to dynamically change the speed value for the Follow Spline script from my OnTriggerEnter function on my custom script.  

Do you have a specific method or approach to easily do this as it seems I am having difficulty accessing and setting variables and functions which use static, private and protected options.  
[/font]
 
Reply
#2
FollowSpline.Speed is a public field, so you can change it from anywhere. Just store a reference to the script instance in your custom script, then change Speed as you like.
Reply
#3
(06-14-2014, 06:03 PM)'Jake' Wrote: FollowSpline.Speed is a public field, so you can change it from anywhere. Just store a reference to the script instance in your custom script, then change Speed as you like.

 
sorry for this noob question but how store the followspline script instance


 
Reply
#4
By having a public field in your Component that stores another Component of type FollowSpline, like:


Code:
public class Test : MonoBehaviour
{
public FollowSpline MyControllerObject;

void Update()
{
MyControllerObject.Speed=10;
}

}
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Newbie Question: Uniformly increase spacing between volume spots? SAMYTHEBIGJUICY 1 5 09-01-2023, 03:38 PM
Last Post: _Aka_
  I have a question about curvySpline haifeng.huang 12 32 07-14-2023, 09:34 AM
Last Post: _Aka_
  Question about generator Mos Def 7 1,807 04-10-2023, 10:20 PM
Last Post: _Aka_
  Change Speed on spline linkinballzpokemon 1 28 12-29-2021, 10:58 AM
Last Post: _Aka_

Forum Jump: