0
\$\begingroup\$

I am making a inline skate game, what could be the best method to code the grinding system, there are many various and complex stuff to use but what could be used to set it up simple and not that complex? I made some research, I come up with Catmull Splines or Bezier curves but that seems very complex, my Idea is getting something simple to build up on that and improve it. Maybe use a simple waypoint system that the player follows along while jump on a trail or something. Any ideas or suggestions? Because you cant find any tutorials on grinding system in YouTube or somewhere.

Thanks.

\$\endgroup\$
4
  • 1
    \$\begingroup\$ What exactly are the requirements for the grinding system in your skate game? Please try to explain it in a way that it is understandable for someone who has never seen your game or a similar one. \$\endgroup\$
    – Philipp
    Jan 26, 2018 at 14:07
  • \$\begingroup\$ I want to use a grinding system like in Jet Set Radio Future, where you hop on and gain more speed by doing tricks while grinding and can jump off whenever you want, it should start grinding where you jump on the trail. \$\endgroup\$
    – Daniel
    Jan 26, 2018 at 17:09
  • \$\begingroup\$ What specific problem have you encountered in making this system? You mention following a trail of waypoints - that sounds feasible. Have you tried implementing it? Did you run into any problems? Are there particular traits of this approach that you want to improve? There's rarely an unambiguous "best" way to do anything in games - just ways that successfully solve specific problems. The more specific you can be about your problem, the better we can help you find solutions. \$\endgroup\$
    – DMGregory
    Jan 30, 2018 at 17:13
  • \$\begingroup\$ I created now a waypoint system I will try to use it then later for the grinding system I will see then if it works for me or not but thanks :) \$\endgroup\$
    – Daniel
    Jan 30, 2018 at 23:30

2 Answers 2

1
\$\begingroup\$

actually catmull splines and bezier curves are probably the easiest method to go about this. there's plenty of plugin's that can provide this kind of functionality. take a look at the leantween plugin, it's great, and you could wrap it into a scriptable object: [link]https://www.assetstore.unity3d.com/en/#!/content/3595 this plugin allows you to define paths, and you could read them out in your code, to get the waypoints. then simply iterate over them. edit: Here's an example of code, set up to create an instance of an LTSpline on a gameObject:

    using UnityEngine;
    using System.Collections;
    using System.Collections.Generic;
    using UnityEditor;


public class PathSpline : MonoBehaviour{
public Color color;

[HideInInspector]
public Vector3[] splinePoints;
    [HideInInspector]
public LTSpline  spline;
public Vector3[] localPts;

int i,j;
[ExecuteInEditMode]
void Start(){
    j = 0;
    GameObject parent = this.gameObject;
    //Vector3[] localPts = new Vector3[splinePoints.Length];
    if (localPts.Length > 2) {
        System.Array.Resize (ref splinePoints, localPts.Length);
    }
    for (j = 0; j < localPts.Length; j++) {
        if(parent.transform.TransformPoint(localPts[j]) != splinePoints [j]){
            splinePoints[j] = parent.transform.TransformPoint(localPts[j]);
        }
    }
    if (splinePoints.Length >= 4) {
        System.Array.Resize (ref spline.pts, splinePoints.Length);
        spline = new LTSpline (splinePoints);

        //System.Array.Resize (ref spline.ptsAdj, splinePoints.Length);
        //spline.ptsAdjLength = splinePoints.Length;
    }
}
\$\endgroup\$
13
  • \$\begingroup\$ I already got LeanTween but dont realy know how to use it properly.. \$\endgroup\$
    – Daniel
    Jan 26, 2018 at 9:57
  • \$\begingroup\$ Well, then it would be better to ask specific questions, like how to implement certain plugins, or how to make a waypoint system in Unity. I have some code that you can use that implements the leantween ltspline in an object. what exactly are you having trouble with? \$\endgroup\$ Jan 26, 2018 at 10:48
  • \$\begingroup\$ I read a bit in the documentary of LeanTween but didnt knew where to start and what to use for my purpose, could you write your code in here that I can see what it could look like? \$\endgroup\$
    – Daniel
    Jan 26, 2018 at 17:10
  • \$\begingroup\$ I edited my answer, i don't think the comment section is great for writing code in. when you have this on an object, you can set up it's points in the editor. after that, in the game, you could do a raycast to find an object with the pathspline component. and use LTSpline.place() or any other function to place an object on the path, or iterate over the points on this object \$\endgroup\$ Jan 27, 2018 at 14:51
  • \$\begingroup\$ I will look when I got time, I will write u then, thanks for now. \$\endgroup\$
    – Daniel
    Jan 27, 2018 at 18:27
1
\$\begingroup\$

Catmull splines and Bezier curves are no doubt the easiest method, although Bezier curves have the downside of not passing through the actual waypoints. Another option is to use Hermite curves.

\$\endgroup\$
2
  • 1
    \$\begingroup\$ Bezier curves do pass through the first and last control point of each segment, the same as Catmull-Rom splines do. For Catmull-Rom splines (which are a special case of cubic Hermite splines), the control points in-between are computed, rather than provided as explicit inputs. You can do the same with Bezier splines so that the curve passes through every explicit input, if you like. In any case, this answer doesn't seem to offer a new strategy beyond what Glenn van Acker described back in January - is there something you'd like to expand on? \$\endgroup\$
    – DMGregory
    May 3, 2018 at 12:30
  • \$\begingroup\$ Bezier curves do indeed pass through the first and last control point, something I forgot to mention. However, in this particular case, i.e grinding in a skating game, I think such rails would be easier to construct & manage when taking a smooth curve that passes through all control points; I've found Bezier curves to be rather unwieldy in the past. Also, they brought up waypoints the player needs to visit. You can do this with Bezier curves, but that doesn't make it easier. I mostly brought up cubic Hermite curves as they are a more general case and can thus provide more flexibility. \$\endgroup\$
    – Nick Dietz
    May 3, 2018 at 12:38

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .