Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Begginer questions
#1
Hi all, 

I'm new user of curvy Smile

And I have some beginner questions Smile

1. How can I move object by 5 units on spline? (i need to make patrol agent that he moves by specific distance on spline)
2. How can I change splines smarter way than entering on trigger? 

Thanks for any help Smile
Reply
#2
Hi Szagi,

1.) Use a SplineController and set it's movement to "Absolute". Speed then means units/second. Enable Animate and set the animation properties if you want a one-shot or tweening behaviour.

2.) I don't understand that, can you please elaborate what you're after?
Reply
#3
Sorry for my bad explanation

1.) I didn't understood this well Sad Animate property can be use for this: my enemy moves for example 5 units, than stops, then change direction and moves 8 units? 

2.)  http://imgur.com/HAjeUPX vertical wall is my trigger which changes splines from down spline to upper spline, but this is a bit jumpy and I have no idea how can I do it smoother Sad

this is my code: 

Code:
void OnTriggerEnter(Collider other)
{
if(other.tag == "Player"){
PlayerSplineController wagon = other.GetComponent<PlayerController>().Wagon;

//TODO:  changing splines is good thing to move to SplineManager
if (wagon != null) {
_enterDirection = Mathf.Sign (wagon.Speed);
Vector3 nearestPoint;
float nearestPointTF;
Transform newParent;
CurvySpline newSpline;

if (direction && _enterDirection > 0 || !direction && _enterDirection < 0 ) {
nearestPointTF = nextSpline.GetNearestPointTF(transform.position,out nearestPoint,7,8);
newSpline = nextSpline;
newParent = nextSpline.transform;
} else {
nearestPointTF = prevSpline.GetNearestPointTF(transform.position,out nearestPoint,6,7);
newSpline = prevSpline;
newParent = prevSpline.transform;
}

wagon.SwitchTo(newSpline, nearestPointTF, 0);
wagon.transform.parent = newParent;
}
}
}
Reply
#4
Hi all,

Can I use navmesh,A star path finding or other path finding algorithm on curvy2.02? may be curvy2.02 already have a best solution for the navigation algorithm.Thanks
Reply
#5
1.) Yeah, see the GUI example scene. The buttons and the label are using the Animate feature, i.e. they move a delta, then move back. But the same Animation feature can be used to move a certain distance and then stop, including slowdowns and other tweanings.

2.) Triggers are one way, another one would be to utilize controller events such as OnEndCPReached/OnCPReached. Then you get a callback each time the controller moves over a CP and you can switch splines there. Use connections to easily access the next/previous spline in question. For some examples, see CurvyDefaultEventHandler.cs.
Reply
#6
1) But from code it is possible? Smile
Reply
#7
You can use the SplineController from code like any other GameObject. All inspector options and commands (stop/start/play/reset etc.) are available by code as well.
Reply
#8
I tried this Animate feature but with more complex AI or a couple move patterns it is a bit messy and hard to control or tweek. There is maybe different way to move something by specific distance from code?
Reply
#9
Yeah, make a custom controller and use Spline API to move the object the way you like, e.g. CurvySpline.MoveByDistanceFast().
Reply
#10
Thanks for all your help Wink You are the best!

I don't understand this method very well, but I created simple custom controller:

Code:
public class EnemyWagonController : SplineController
{
private float _tfValue;
private int _direction = 1;

void Awake()
{
Vector3 nearestPoint;
_tfValue = Spline.GetNearestPointTF (transform.localPosition, out nearestPoint);
transform.localPosition = nearestPoint;
}

public override void Refresh ()
{
Move ();
}

void Move()
{
Vector3 nearestPoint;
_tfValue = Spline.GetNearestPointTF (transform.localPosition, out nearestPoint);
transform.localPosition = Spline.MoveByLengthFast (ref _tfValue, ref _direction, 2f, CurvyClamping.PingPong);
}
}

And I assume MoveByLengthFast(ref float tf, ref int direction, float distance, CurvyClamping clamping) distance is speed, but how can I track my controller reached target distance? Wink

Sorry for my stupid questions.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Questions about Generator: mesh/objects within spline, snap to control point dartboard 5 954 06-09-2021, 12:42 PM
Last Post: _Aka_
  Controller speed questions Lupp_ 6 1,568 01-20-2021, 09:20 PM
Last Post: _Aka_
  General questions about this asset for a sim game jamesunity 6 2,711 08-01-2020, 04:53 PM
Last Post: _Aka_
  Some Questions about useful function I need UsernameHed 5 4,127 05-06-2019, 02:22 PM
Last Post: _Aka_

Forum Jump: