03-21-2016, 10:07 AM
Sorry for my bad explanation
1.) I didn't understood this well 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
this is my code:
1.) I didn't understood this well 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
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;
}
}
}