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
  Pre-Purchase question discofever 1 106 11-03-2020, 12:15 PM
Last Post: _Aka_
Question Changing speed between ControlPoints funkd 5 604 10-02-2020, 12:36 PM
Last Post: _Aka_
  Question regarding Spline Generated Path linkinballzpokemon 9 1,513 07-01-2020, 06:10 PM
Last Post: _Aka_
  Control points / performance question dazz777 3 924 04-17-2020, 02:40 PM
Last Post: _Aka_

Forum Jump: