Search Unity

Snowboard Game Starter (Template)

Discussion in 'Assets and Asset Store' started by FreebordMAD, Dec 4, 2015.

  1. Water-tight

    Water-tight

    Joined:
    Oct 17, 2021
    Posts:
    16
    To further clarify, I just want it so the character never stops when moving sideways and instead just keeps on riding no matter how much tilt.
     
  2. Water-tight

    Water-tight

    Joined:
    Oct 17, 2021
    Posts:
    16
    Hello again. I was able to edit it so it now doesnt slow down when using A or D. I don't need help with that anymore, however, now I instead need help because when moving left or right it moves very slowly (regardless of which speed the player is going). Could you please help with this? Thanks in advance.
     
  3. FreebordMAD

    FreebordMAD

    Joined:
    Mar 15, 2013
    Posts:
    633
    Sorry for the late reply, unfortunately my availability is very limited and also without understanding more about your game I cannot provide more code. I fear that I currently can't help much more
     
  4. Water-tight

    Water-tight

    Joined:
    Oct 17, 2021
    Posts:
    16
    Do you not have any solutions to make the player go faster when going left or right? Simply put I would like the player to move faster side to side, I understand your time is limited.
     
  5. FreebordMAD

    FreebordMAD

    Joined:
    Mar 15, 2013
    Posts:
    633
    Please explain with some sketches. Side to side like in a line racer game?

    You could increase ACCELERATION_FORCE in PlayerConfig script when the player is going left or right
     
  6. Water-tight

    Water-tight

    Joined:
    Oct 17, 2021
    Posts:
    16
    Hopefully the picture below explains what im looking for. Let's say for example that the player has pressed A (going left) for 0.3 seconds. Currently, they would be where the blue player is. What I want is when the player has pressed A for the same amount of time they instead end up at red.

    Basically that they turn around faster. I've tried using acceleration force but to no luck unforunetly, I've tried around with every setting but can't seem to find anything that helps me with this. You gave an excellent reply previously when I wanted the character to stop slowing down, now I just need help with the character turning/going faster to the sides. ed01d634b5998ed3fa3703127e781e4a copy.png
     
  7. FreebordMAD

    FreebordMAD

    Joined:
    Mar 15, 2013
    Posts:
    633
    You can try to increase FLAT_ROT_SPEED - this will make the player rotate faster, but it will lead also to faster rotation for 180 degree.
    upload_2022-12-28_19-59-14.png


    Alternatively play with FRICTION_FACTOR_* constants and increase them in the PlayerPhysicsHandler class.
    upload_2022-12-28_20-21-57.png
     
  8. Water-tight

    Water-tight

    Joined:
    Oct 17, 2021
    Posts:
    16
    Thank you for your reply. When I try adding another model, an issue occurs when the character "dies", and what happens is that they get stuck in that place and you can still rotate the model and it floats in the air.

    f7b2a543f7e05b9877ae36309c72ff00.png

    I've tried this with several models including the test one included in Characters/Customexample

    Do you have any idea to why this is? I follow step by step the guide multiple times, tried several rigs but nothing works. Help would really be appreciated.
     
  9. FreebordMAD

    FreebordMAD

    Joined:
    Mar 15, 2013
    Posts:
    633
    Are there any errors in the log?
    Seems like the dead body ragdoll is not found
     
  10. Water-tight

    Water-tight

    Joined:
    Oct 17, 2021
    Posts:
    16
    I was able to solve it. If anyone on the future has this problem, make sure you follow every step and also add the audio source. I didn't want to add the audio or think it was necesseary, but without it the ragdoll doesn't register.

    I was wondering, I have asked this before and you gave a solution. It's regarding the character slowing down when going left or right, and if you go left or right far enough the character will completetly stop.

    I was wondering if there is anything in the code that I just can remove to stop this? Or is there too much code or too complicated to do? You gave an example code which works, but it messes with other settings. I'm just wondering if there is way to completetly remove the mechanic of the player slowing down when moving left or right. (Note, this is not about acceleration, but the other mechanic where the player goes completetly sideways after moving too much left or right).

    Edit: I can show examples if you don't understand which mechanic im referring to, and if its too complicated to remove it due to the amount of code then I understand that also.
     
  11. FreebordMAD

    FreebordMAD

    Joined:
    Mar 15, 2013
    Posts:
    633
    Find the comment marked green in PlayerPhysicsHandler, then add the two bold lines to the code

    // make the end of the slide smoother (less breaking on low lateral velocity)
    if (lateralVSign * lateralV < LATERAL_V_SMOTHER)
    {
    vLossDueToFriction *= (lateralVSign * lateralV) / LATERAL_V_SMOTHER;
    }

    Vector3 vLoss;
    float vLenTemp = m_playerStrl.Velocity.magnitude;
    if (lateralVSign * lateralV < vLossDueToFriction)
    {
    // stop the slide -> carve
    vLoss = lateralDirection * lateralV ;
    m_lastSlideV = 0.0f;
    m_playerStrl.Velocity = m_playerStrl.Velocity - vLoss;
    }
    else
    {
    // apply some (lateral)friction
    vLoss = lateralVSign * lateralDirection * vLossDueToFriction;
    m_lastSlideV = lateralV - vLossDueToFriction;
    m_playerStrl.Velocity = m_playerStrl.Velocity - vLoss;
    }
    m_playerStrl.Velocity *= vLenTemp / m_playerStrl.Velocity.magnitude;
    m_lastSlideVLoss += vLoss;
     
    Water-tight likes this.
  12. Water-tight

    Water-tight

    Joined:
    Oct 17, 2021
    Posts:
    16
    Hello! Thanks for previous reply, helped a ton, I gave a 5 star review! I just wonder about animation, in which script do I want to modify this? For example I want to add a crouch animation. Do I have to edit multiple scripts or just one?
     
  13. Water-tight

    Water-tight

    Joined:
    Oct 17, 2021
    Posts:
    16
    Hello it's me again. I want to add more features than what is included in the original package to the game I'm making. I know you're busy with work, but if you have a little time on the side I would like your help (paid of course). Let me know what you think.
     
  14. AltIvan

    AltIvan

    Joined:
    Aug 3, 2013
    Posts:
    14
    I purchased the asset and my vote is only and only for "NPC characters to race against"
     
  15. Vaultcom

    Vaultcom

    Joined:
    Mar 12, 2022
    Posts:
    1
    I have this error when I try to build in android and iOS:

    Shader error in 'Custom/SnowTrailShaderTextured: invalid subscript 'staticLightmapUV'

    Please help.
     
  16. AltIvan

    AltIvan

    Joined:
    Aug 3, 2013
    Posts:
    14
    I was able to create very dumb NPCs but it will have to do for now, if anyone cares about creating something similar read on: The NPC just follows empty transforms that I manually created in the correct order (from start-line to finish-line I mean, in the editor that means top to bottom as children of a GameObject called "NPC Path"), a bunch of spheres with "isTrigger" set to true (and renderer disabled to make them invisible).

    Using a modified version of the PlayerInput class, I mostly changed the SetActiveIndex method, I got the main idea from the tutorial at the end of this post, I also had to make a few other changes to copy "PlayerAlive" but the error messages plus playing it out should help you fix all of that. happy coding.

    Code (CSharp):
    1.  
    2. using UnityEngine;
    3. using System.Collections;
    4. using System.Collections.Generic;
    5. using System.Linq;
    6.  
    7. namespace Snowboard
    8. {
    9.     public class NpcInput : IInput
    10.     {
    11.         private float _AxisX = 0;
    12.         private float _AxisY = 0;
    13.         private bool _IsJump = false;
    14.         private bool _IsSlide = false;
    15.         private bool _IsGrab = false;
    16.  
    17.         private PlayerController p_playerCtrl;
    18.         private Rigidbody p_cachedRigidBody;
    19.  
    20.         private List<Transform> targets = new List<Transform>();
    21.  
    22.         private Transform _target;
    23.  
    24.         // contrusctor
    25.         public NpcInput () {
    26.        
    27.         }
    28.  
    29.         public NpcInput (PlayerController playerCtrl, Rigidbody cachedRigidBody) {
    30.             this.p_playerCtrl = playerCtrl;
    31.             this.p_cachedRigidBody = cachedRigidBody;
    32.         }
    33.         private void Update () {
    34.        
    35.         }
    36.  
    37.         public override float AxisX
    38.         {
    39.             get
    40.             {
    41.                 return _AxisX;
    42.             }
    43.         }
    44.  
    45.         public override float AxisY
    46.         {
    47.             get
    48.             {
    49.                 return _AxisY;
    50.             }
    51.         }
    52.  
    53.         public override bool IsJump
    54.         {
    55.             get
    56.             {
    57.                 return _IsJump;
    58.             }
    59.         }
    60.  
    61.         public override bool IsSlide
    62.         {
    63.             get
    64.             {
    65.                 return _IsSlide;
    66.             }
    67.         }
    68.  
    69.         public override bool IsGrab
    70.         {
    71.             get
    72.             {
    73.                 return _IsGrab;
    74.             }
    75.         }
    76.  
    77.         public override void Draw () {}
    78.  
    79.         public override void SaveCurrentAsCalibration () { }
    80.  
    81.         public override void Create (EPlayers p_index) {
    82.             // This acts like Start
    83.             targets = GameObject.Find("NPC Path").GetComponentsInChildren<Transform>().ToList();
    84.             targets.RemoveAt(0);
    85.         }
    86.  
    87.         public override void Destroy (EPlayers p_index) { }
    88.  
    89.         public override void DestroyAll () { }
    90.  
    91.         Transform prevTarget = null;
    92.  
    93.         public override void SetActiveIndex (EPlayers p_activePlayer) {
    94.             // This acts like OnUpdate
    95.        
    96.             Vector3 prevDiff = prevTarget != null ? prevTarget.position - p_playerCtrl.transform.position : Vector3.zero;
    97.             Vector3 diff = prevTarget != null ? _target.position - p_playerCtrl.transform.position : Vector3.zero;
    98.        
    99.             if (_target != null && Vector3.Distance(p_playerCtrl.transform.position, _target.position) < 2
    100.             // or if the difference between the new-one-vs-NPC-transform share the same sign as
    101.             // the previous-one-vs-NPC transform we assume is behind
    102.             || (prevTarget != null
    103.                 && Vector3.Distance(p_playerCtrl.transform.position, prevTarget.position) > 2.5f
    104.                 && Mathf.Sign(prevDiff.x) == Mathf.Sign(diff.x)
    105.                 && Mathf.Sign(prevDiff.z) == Mathf.Sign(diff.z)
    106.             )) {
    107.                 prevTarget = _target;
    108.                 targets.RemoveAt(0);
    109.             }
    110.  
    111.             if (targets.Count == 0) {
    112.                 // already reached the end of the race track
    113.                 return;
    114.             }
    115.             _target = targets[0];
    116.             Vector3 dirToMovePosition = (_target.position - p_playerCtrl.transform.position).normalized;
    117.             float dot = Vector3.Dot(dirToMovePosition, p_playerCtrl.BordDirection);
    118.             float angleToDir = Vector3.SignedAngle(p_playerCtrl.BordDirection, dirToMovePosition, Vector3.up);
    119.  
    120.             if (Mathf.Abs(angleToDir) < 0.05f) {
    121.                 // we are facing the target
    122.                 // move towards it
    123.                 _AxisX = 0;
    124.             } else if (angleToDir > 0) {
    125.                 _AxisX = -1;
    126.             } else {
    127.                 _AxisX = 1;
    128.             }
    129.        
    130.         }
    131.        
    132.     }
    133.  
    134. }
    135.  
    136.  
     
    Last edited: May 25, 2023
    FreebordMAD likes this.
  17. Water-tight

    Water-tight

    Joined:
    Oct 17, 2021
    Posts:
    16
    Simple question, how to get the rails working? Followed the few steps there are but doesn't seem to be working..
     
  18. FreebordMAD

    FreebordMAD

    Joined:
    Mar 15, 2013
    Posts:
    633
    What exactly is not working? What is your setup?
     
  19. Water-tight

    Water-tight

    Joined:
    Oct 17, 2021
    Posts:
    16
    The player is not sticking to the rails. These are the steps I took:

    1. Added a model to the scene
    2. Added the PlayerMovementLocker script to that model/object
    3. Create empty objects on the model, one at the start of the model, one in the middle and one in the end
    4. Assign the empty objects to the lockpoints property

    Is there any step I'm missing or doing incorrectly?
     
  20. FreebordMAD

    FreebordMAD

    Joined:
    Mar 15, 2013
    Posts:
    633
    The model has a collider, right?
     
  21. Water-tight

    Water-tight

    Joined:
    Oct 17, 2021
    Posts:
    16
    Yes the model has a collider. Do you think you could do a small recording of the steps? Tried several different ways but no results unfortunately
     
  22. FreebordMAD

    FreebordMAD

    Joined:
    Mar 15, 2013
    Posts:
    633
    I'm not sure when I will find the time, could you instead send screenshots of the inspector with the collider, the empty GOs, the script and the tagged object?
     
  23. FreebordMAD

    FreebordMAD

    Joined:
    Mar 15, 2013
    Posts:
    633
    I was made aware of a bug in the score calculation - I'm shocked nobody reported it for so long!

    In the UILevel class there is a little typo, it is "+=", but it should be only "=".

    upload_2023-8-12_22-36-52.png

    For anyone stumbling across this, feel free to replace the whole file with the attached one if you didn't change it, otherwise just remove the + in the first line of UILevel.OnReportScore.

    Alternatively, just replace the UILevel.OnReportScore function with eh below code:
    Code (CSharp):
    1.         public void OnReportScore(PlayerScoreHandler.ScoreData p_scoreData)
    2.         {
    3.             m_levelScore = p_scoreData.Score;
    4.             if (m_scoreText != null)
    5.             {
    6.                 m_scoreText.text = "Score: " + m_levelScore + "\n" + p_scoreData.TrickName;
    7.             }
    8.         }
     

    Attached Files:

  24. WaterUnicorn

    WaterUnicorn

    Joined:
    Oct 4, 2022
    Posts:
    1
    Hello,

    My goal is to use your template and create a skiing game based on it instead of snowboarding. I find your work very professional and well organized and I am very thankful I came across your template.
    I would like some general guidelines from you on what needs to be modified for my use case. I have a skiing player character already with animations that I'd like to use and my first goal is to integrate it with your template.

    Thank you!

    Cheers,
    Pavel
     
  25. bobadi

    bobadi

    Joined:
    Jan 3, 2019
    Posts:
    672
    hi, could you upload a urp-free version? just the physics (and animator if is there)...

    I thought I could just remove the URPassets folder, but it is tied up in quality settings and all kinds of dependancies. is it possible?

    and there is a missing script reference on prefab. ok, if I open, I see it's PlayerController and PlayerDamper, two spheres, it look like a nice design. it would be great to open it in built-in.
     
  26. BusterDev

    BusterDev

    Joined:
    Mar 21, 2022
    Posts:
    18
    Strange question I know but would really appreciate if could tell me how to change the color of the snow effects?