Search Unity

[RELEASED] Complete Physics Platformer Kit

Discussion in 'Assets and Asset Store' started by Greg-Sergeant, Oct 2, 2013.

  1. DanielSnd

    DanielSnd

    Joined:
    Sep 4, 2013
    Posts:
    382
    Old problem, already solved:
    http://forum.unity3d.com/threads/released-complete-physics-platformer-kit.203279/page-9#post-1713353
     
  2. Besus

    Besus

    Joined:
    Mar 9, 2014
    Posts:
    226
    That's the rigidbody going to sleep (that was mentioned a few pages ago in this thread too) and preventing the collision.

    You can fix that by adding rigidbody.WakeUp(); to the Update() statement on a script attached to the player (like PlayerMove).
     
  3. Bentlman1981

    Bentlman1981

    Joined:
    Jun 24, 2014
    Posts:
    9
    This kit and it's addons are truly awesome. has anybody using the melee and ranged attack addons discovered a way to have the player stop moving while doing those actions? Or not really so much the stopping but perhaps something like stay facing the same way as long as the fire/attack button is down?
     
    Last edited: Nov 5, 2014
  4. Besus

    Besus

    Joined:
    Mar 9, 2014
    Posts:
    226
    You would have to lock the rotation if you wanted them to keep facing the same direction (the best way would be to set a bool and if true, bypass running: characterMotor.RotateToDirection in the FixedUpdate() function). The same logic could be applied to preventing movement while attacking, and either disabling the math taking place for moveDirection in Update() or bypassing characterMotor.MoveTo in FixedUpdate().
     
  5. Bentlman1981

    Bentlman1981

    Joined:
    Jun 24, 2014
    Posts:
    9
    Thank you so much. I hope to one day be as knowledgeable with coding.
     
  6. serkanos

    serkanos

    Joined:
    Jan 12, 2013
    Posts:
    28
    Last edited: Nov 6, 2014
  7. Besus

    Besus

    Joined:
    Mar 9, 2014
    Posts:
    226
  8. serkanos

    serkanos

    Joined:
    Jan 12, 2013
    Posts:
    28
    Very thnks :) I will publish for ios soon. But I dont know standalone how do I publish. But I want to.
     
  9. Besus

    Besus

    Joined:
    Mar 9, 2014
    Posts:
    226
    Just change the platform in your build settings to PC And Mac Standalone and it will compile it to an executable: http://docs.unity3d.com/Manual/PublishingBuilds.html
     
  10. serkanos

    serkanos

    Joined:
    Jan 12, 2013
    Posts:
    28
    Ok I will try :)
     
  11. Deleted User

    Deleted User

    Guest

    hello!
    I have question: how can I make "push force" in Hazard only in x direction ?

    thanks!

    by the way
    the physics kit is really amazing thing!!
     
  12. Besus

    Besus

    Joined:
    Mar 9, 2014
    Posts:
    226
    Just set the public variable for "Push Height" to 0 in the Hazard script so that it will (technically) only apply the "Push Force".
     
  13. Deleted User

    Deleted User

    Guest

    yes, but push force is working in both x and z direction, I need only x direction
     
  14. Besus

    Besus

    Joined:
    Mar 9, 2014
    Posts:
    226
    I haven't tested it, but in DealDamage.cs, remove line 19:
    Code (CSharp):
    1. victim.rigidbody.AddForce (pushDir.normalized * pushForce, ForceMode.VelocityChange);
    And replace it with:
    Code (CSharp):
    1. Vector3 newPushV3 = pushDir.normalized * pushForce;
    2. newPushV3.y = 0f;
    3. newPushV3.z = 0f;
    4. victim.rigidbody.AddForce (newPushV3, ForceMode.VelocityChange);
     
  15. Wonkee

    Wonkee

    Joined:
    Jan 7, 2014
    Posts:
    13
    Drop this script on an object to turn it into a health boost.

    Code (csharp):
    1.  
    2. using UnityEngine;
    3. using System.Collections;
    4.  
    5. public class HeartPickup : MonoBehaviour
    6. {
    7.     public AudioClip heartSound;
    8.  
    9.     private Transform player;
    10.     private Health health;
    11.  
    12.         // Use this for initialization
    13.         void Start ()
    14.         {
    15.             player = GameObject.FindGameObjectWithTag("Player").transform;
    16.             health = GameObject.FindGameObjectWithTag("Player").GetComponent<Health>();
    17.         }
    18.  
    19.         //give player health when it touches them
    20.         void OnTriggerEnter(Collider other)
    21.         {
    22.             if (other.tag == "Player")
    23.                 HeartGet();
    24.         }
    25.  
    26.         void HeartGet()
    27.         {
    28.             if(heartSound)
    29.                 AudioSource.PlayClipAtPoint(heartSound, transform.position);
    30.             Destroy(gameObject);
    31.             if (health.currentHealth < 3)
    32.                 health.currentHealth = health.currentHealth + 1;
    33.         }
    34. }
    35.  
     
    Last edited: Nov 13, 2014
  16. Deleted User

    Deleted User

    Guest

    thanks Besus!! it's working now
     
  17. Besus

    Besus

    Joined:
    Mar 9, 2014
    Posts:
    226
    It's important to note that this script will need to have a Collider set to Trigger attached to the game object for it to work. Also, to make some minor optimizations here (since it's a modified version of the Coin script), there's no need to use resources (albeit minor) to cache the reference to the player transform as it's never used:
    Code (CSharp):
    1. player = GameObject.FindGameObjectWithTag("Player").transform;
    Since unlike the coin, this health pickup doesn't need the transform to find and "spin" toward the player like the coin does.

    Lastly for the HeartGet method, you can save some code in that last line by changing:
    Code (CSharp):
    1. health.currentHealth = health.currentHealth + 1;
    To:
    Code (CSharp):
    1. health.currentHealth += 1;
    Giving you:
    Code (CSharp):
    1.  
    2. using UnityEngine;
    3. using System.Collections;
    4.  
    5. public class HeartPickup : MonoBehaviour
    6. {
    7.     public AudioClip heartSound;
    8.     private Health health;
    9.  
    10.         void Start ()
    11.         {
    12.             health = GameObject.FindGameObjectWithTag("Player").GetComponent<Health>();
    13.         }
    14.  
    15.         void OnTriggerEnter(Collider other)
    16.         {
    17.             if (other.tag == "Player")
    18.                 HeartGet();
    19.         }
    20.  
    21.         void HeartGet()
    22.         {
    23.             if(heartSound)
    24.                 AudioSource.PlayClipAtPoint(heartSound, transform.position);
    25.             Destroy(gameObject);
    26.             if (health.currentHealth < 3)
    27.                 health.currentHealth += 1;
    28.         }
    29. }
    Ideally you could also be able to get the player health at the time of the collision with something like:
    Code (CSharp):
    1. void OnTriggerEnter(Collider other)
    2. {
    3.        if (other.tag == "Player")
    4.        {
    5.               health = other.GetComponent<Health>();
    6.               HeartGet();
    7.        }
    8. }
    Since then you won't be performing a find of the target object, but since it takes place at scene start it shouldn't have that big of an impact (although with enough of them, I could see it causing some performance issues on mobile devices). But if Daniel reads this, I'm sure he could go in to all sorts of details about using singletons instead. ;)
     
  18. DanielSnd

    DanielSnd

    Joined:
    Sep 4, 2013
    Posts:
    382
    I read it, and the first thing that came to my mind was "SINGLETONS!", but I decided to keep my mouth shut hahahaha
    If anyone does want to learn more about singletons, http://unitypatterns.com/singletons/
     
  19. Bentlman1981

    Bentlman1981

    Joined:
    Jun 24, 2014
    Posts:
    9
    Hello everybody, My character that I've imported is working totally fine and I have him all set up and animated. The only thing that is happening is that when he runs into an enemy and bounces or maybe other cases he is knocked off rotation and stays that way so that for example I will run straight up and he will move straight up but he will be facing up and left only after being hit.. I have this set up the same way It is in the 3D demo and have not messed with any scripts.

    He becomes completely removed from the Player gameObject if I keep playing so that he will rotate around the game object like the hands on a clock.

    Edit : If anyone else has this issue, it was the Animator I had to uncheck apply root motion.
     
    Last edited: Nov 15, 2014
  20. Triconcept

    Triconcept

    Joined:
    Apr 17, 2013
    Posts:
    11
    Hey guys must say I'm loving this kit and all the add-ons. It's come a long way from it's "original" state. I do have a question. Has anyone tried to implement a third attack for Daniel's melee script? I have contacted you Daniel from ur website and have tried finding your email so I wouldn't have to ask here but to no avail. However it's occurred to me that I'm prob not the only one who is wondering this. I have looked into scripting, and have optimized a lot of codes, so I know some but not that much. I have spent hrs for the past week now trying to get a third melee attack. However It keeps coming up with errors in the console. Once I get home fro mwork I will continue to look and see if I can find a solution to load a third melee attack. I believe it's just mis-coded with the " } else {" part that begins stating the third melee attack. I have made a third state in the animator with the correct name and have it transitioning just like the punch left and right animations in animator. Any advice or solutions would be greatly appreciated. Thanks to Daniel and Besus I decided to look into coding and I have created a script where the character enables or disables the melee attack by drawing/ withdrawing their weapon.
    Here's the part of the melee script, where I attempted to implement the third attack.
    Code (CSharp):
    1. // Update is called once per frame
    2.     void Update () {
    3.         if (CFInput.GetKeyDown(KeyCode.Z)) {
    4.             //First off, let's check if we're not already punching,
    5.             //see if the punch animations are playing on Layer 1 (The one with the arms).
    6.             if(!CheckIfPlaying("RightPunch",1)&&!CheckIfPlaying("LeftPunch",1)&&!CheckIfPlaying("ThirdPunch",1)) {
    7.                 //If I got here no punch animations are playing so we can punch now :D
    8.                 if(punchleft) {
    9.                     //Tell the anim ator to play the left punch, and change the bool so next punch will be right punch!
    10.                     playerMove.animator.Play("LeftPunch",1);
    11.                     punchleft=false;
    12.                     //Then start the coroutine so the punch effect happens when the animation already reached the interest part.
    13.                     StartCoroutine(WaitAndPunch());
    14.                 } else {
    15.                     playerMove.animator.Play("RightPunch",1);
    16.                     punchleft=true;
    17.                     StartCoroutine(WaitAndPunch());
    18.                 } else {
    19.                     playerMove.animator.Play("ThirdPunch",1);
    20.                     punchleft=true;
    21.                     StartCoroutine(WaitAndPunch());
    22.                 }
     
  21. Besus

    Besus

    Joined:
    Mar 9, 2014
    Posts:
    226
    You're getting errors because you have a third branch to the if statement. You're basically saying, if we're supposed to punch with left, do this - else do this - (and then the problem part of) saying else again. This can be remedied by changing the first else statement to 'else if (insert criteria)'.
    Basically stating:
    • If we meet these criteria, do this action
    • Else if we meet these criteria do this, but if we meet none of these first two
    • Then do this regardless.
    You would also likely have to introduce a new bool in to the mix for that third action since there's nothing to state when we should play the third (as of right now, you have no condition to meet for the engine to decide what to do when.

    So for this example create a new bool at the top of the script to something like:
    Code (CSharp):
    1. private bool thirdPunch = false;
    Then you can use the following:
    Code (CSharp):
    1. if (punchleft && !thirdPunch)
    2. {
    3.     //Tell the anim ator to play the left punch, and change the bool so next punch will be right punch!
    4.     playerMove.animator.Play("LeftPunch",1);
    5.     punchleft = false;
    6.     //Then start the coroutine so the punch effect happens when the animation already reached the interest part.
    7.     StartCoroutine(WaitAndPunch());
    8. }
    9. else if (!punchLeft && !thirdPunch)
    10. {
    11.     playerMove.animator.Play("RightPunch",1);
    12.     punchleft=true;
    13.     thirdPunch = true;
    14.     StartCoroutine(WaitAndPunch());
    15. }
    16. else
    17. {
    18.     playerMove.animator.Play("ThirdPunch",1);
    19.     thirdPunch = false;
    20.     StartCoroutine(WaitAndPunch());
    21. }
    Now we're stating the following:
    • If punchLeft is true but thirdPunch is false, do this
    • If punchLeft and thirdPunch are not true, we do this
    • If none of the above conditions are met, do this.
     
  22. Triconcept

    Triconcept

    Joined:
    Apr 17, 2013
    Posts:
    11
    @Besus Thank you so much for not only showing me why but explaining in detail. I actually made another bool for the third punch animation to be called yesterday. I scrapped it though thinking there was an easier way. At least I now know that I was headed in the right direction. I will try to use that fix and see what happens. ^ ^ Also
    @Besus did you teach yourself what you know of programming? I have taken a couple classes but I have learned more using Unity 3d than I have over those two years in the classes. Heh, go figure....
     
  23. mradamnoble

    mradamnoble

    Joined:
    Nov 17, 2014
    Posts:
    2
    I wonder if there's anyone who can help me. I don't know if this topic has been brought up previously so I apologise if it has. I want to add collision to my main camera. I'm using the follow script which came with the package on the camera and it seems the avoid clipping tags don't work very well and doesn't give the desired effect I need. Basically I want it to hit anything I tell it to and either bounce the opposite way slightly or do what the clipping tags is already trying to do but better :/ Also it seems when I add a collider to the camera it doesn't collide with anything else in the scene regardless of whether it has a collider or not. Is this something he set up in the script? I'm not very good with script so I rely on Playmaker for the most part. I can get the camera to tell me when it hits a wall/object but that's as far as I've got. Thanks camerathrough.png
     
  24. Triconcept

    Triconcept

    Joined:
    Apr 17, 2013
    Posts:
    11
    If you look in the asset store there are some good camera scripts. I'm using "Master Camera" on mine. It detects with layers and tags. It uses layers for objects you want it to "phase" through. It will zoom in on the player to avoid "going through" walls and objects identified with certain tags. I have heard you can add a collider to a camera itself and change the clipping near to 0.01. I tried it though and it didn't work for me, however it works for some...I think it depends which version of Unity 3d you're using. "Master Camera cost $10. It is well worth that price. There are others in the store as well but I think it's the cheapest. Oh if you do use Master Camera then change the player's layer. It won't effect anything concerning how the player reacts in this project. It will however keep the camera from zooming in and out when player jumps. Coding your own would be difficult, and take time. People could point you in the right direction, however there is no "easy fix" for the later versions of Unity as far as camera collision. Sorry if you were hoping for a "quick fix." I'm not that good at scripting yet so here's an example of what "Master Camera does.
    Btw cool lookin game!!!! :D
     
    Last edited: Nov 17, 2014
  25. mradamnoble

    mradamnoble

    Joined:
    Nov 17, 2014
    Posts:
    2
    Hey thanks! That's just what I was looking for. Saved me a major headache. I had looked for something similar but alot of them just gave me more headaches with having to use certain animation sets and so on. But this is great it fits around what I already have :) Thanks again
     
  26. Triconcept

    Triconcept

    Joined:
    Apr 17, 2013
    Posts:
    11
    Np my friend! Yeah after spending hrs trying to code one myself I thought, "hmm..asset store." Lol. My email is Triconcept88@gmail.com if ya have any questions or need any more help. Happy gaming! :D
     
  27. Besus

    Besus

    Joined:
    Mar 9, 2014
    Posts:
    226
    Do those scripts work along side with the standard CameraFollow script or do they replace it? I'd probably wind-up looking in to that as well as the camera clipping can sometimes be a bit jarring with the standard CameraFollow script. I spent about an hour or so working with Daniel trying to revamp the existing one's clipping mechanics/math but we couldn't get it to work as we hoped. :(

    So if the Master Camera script(s) work alongside the CameraFollow script, I would probably snap it up as well. :cool:
     
  28. Triconcept

    Triconcept

    Joined:
    Apr 17, 2013
    Posts:
    11
    It replaces it completely. It offers a "3rd" person view where the camera stands behind the character. You can adjust the height's for it though. Also has a list of other "following" options. The horizontal will allow rotation, I have disabled the mouse zoom so it will zoom in automatically to the character once collision is detected. The system is comprised primarily of 2 scripts working together. After playing around with the settings in the editor (not recoding) lol I have it working in my project and plan to use it for future games I'll be working on. Here's an example pic to give you guys an idea of how it works. Hope this helps you guys. It's been a great asset to me so far, and hasn't effected performance. The fact that it can make meshes transparent is also a plus. You can identify what is to be avoided and what should be transparent through the editor. Just add what tags it needs to look for as well as layer. Also make sure you guys change the enemies layer too, not tag. Or else the camera will bump into enemies and cause unexpected shaking.
     
  29. Besus

    Besus

    Joined:
    Mar 9, 2014
    Posts:
    226
    After playing the web demo, I sort of gathered that it would be a replacement. Given I have additional code in my CameraFollow script (for first-person toggle and the like) I may just check out the asset to play with the collision code that it uses and integrate that in to the CameraFollow script. :)
     
  30. Triconcept

    Triconcept

    Joined:
    Apr 17, 2013
    Posts:
    11
    Not a bad idea my friend. It appears to mainly use the layers as indication for collision and not so much with tags. Might be a reason why your script isn't as successful..?? Idk since I'm not sure what you're using with your script. Either way I'm sure you could integrate what ya need. Good luck and hope it works out for ya. ;)
     
  31. Wonkee

    Wonkee

    Joined:
    Jan 7, 2014
    Posts:
    13
    Im working on a pound/slam script. I started out with DanielSnd's PlayerMelee script and modified it.

    How would I make this script do damage based on the distance the player falls before hitting a rigidbody?

    Code (csharp):
    1.  
    2. using UnityEngine;
    3. using System.Collections;
    4. using System.Collections.Generic;
    5.  
    6. public class GroundPound : MonoBehaviour {
    7.    
    8.     //We'll use those 3 to communicate with the rest of the kit.
    9.     private PlayerMove playerMove;
    10.     private CharacterMotor characterMotor;
    11.     private DealDamage DoDamage;
    12.  
    13.     //This will be used to check if we should be dealing damage.
    14.     private bool pounding;
    15.     private bool grounded;
    16.    
    17.     private List<GameObject> BeingPounded = new List<GameObject>();
    18.    
    19.     //These are our public vars, PoundHitBox should be like the GrabBox,
    20.     //and should encompass the area you want your punch to cover
    21.     public BoxCollider PoundHitBox;  
    22.  
    23.     public int PoundDamage = 1;
    24.     public float PushHeight = 6;
    25.     public float PushForce = 12;
    26.     public Vector3 PoundForce = new Vector3(0, 40, 0);
    27.  
    28.     void Start () {
    29.         playerMove = GetComponent<PlayerMove>();
    30.         characterMotor = GetComponent<CharacterMotor>();
    31.         DoDamage = GetComponent<DealDamage>();
    32.  
    33.         PoundHitBox.enabled=false;
    34.     }
    35.    
    36.     // Update is called once per frame
    37.     void Update () {
    38.         grounded = playerMove.animator.GetBool("Grounded");
    39.         if (CFInput.GetKeyDown(KeyCode.LeftShift) && !grounded && !pounding) {
    40.             pounding = true;
    41.             StartCoroutine(WaitAndPound());
    42.         }
    43.     }
    44.    
    45.     IEnumerator WaitAndPound()
    46.     {
    47.         yield return StartCoroutine(Wait(0.12f));
    48.         PoundThem();
    49.     }
    50.  
    51.     IEnumerator Wait(float duration)
    52.     {
    53.         for (float timer = 0; timer < duration; timer += Time.deltaTime)
    54.             yield return 0;
    55.     }
    56.    
    57.     void PoundThem() {
    58.  
    59.         PoundHitBox.enabled = true;
    60.         pounding = true;
    61.         rigidbody.velocity = new Vector3(rigidbody.velocity.x, 0f, rigidbody.velocity.z);
    62.         rigidbody.AddRelativeForce (PoundForce, ForceMode.Impulse);
    63.     }
    64.  
    65.     void OnTriggerStay(Collider other) {
    66.         if(!pounding) {
    67.             return;
    68.         }
    69.         if (other.attachedRigidbody&&other.gameObject.tag!="Player") {
    70.             //If this object in our trigger is not on our list of stuff pounded this time
    71.             if(!BeingPounded.Contains(other.gameObject)) {
    72.                 //Call the DealDamage script telling it to punch the hell out of this guy
    73.                 DoDamage.Attack(other.gameObject,PoundDamage,PushHeight,PushForce);
    74.                 //Add him to the list, so we won't hit him again.
    75.                 BeingPounded.Add(other.gameObject);
    76.             }
    77.         }
    78.         pounding = false;
    79.         //Disable Hitbox
    80.         PoundHitBox.enabled=false;
    81.         //Clear the List of people that got pounded
    82.         BeingPounded.Clear();
    83.     }
    84.    
    85.     //This will return a TRUE/FALSE on the animation we want to check if is playing.
    86.     bool CheckIfPlaying(string Anim,int Layer) {
    87.         //Grabs the AnimatorStateInfo out of our PlayerMove animator for the desired Layer.
    88.         AnimatorStateInfo AnimInfo = playerMove.animator.GetCurrentAnimatorStateInfo(Layer);
    89.         //Returns the bool we want, by checking if the string ANIM given is playing.
    90.         return AnimInfo.IsName(Anim);
    91.     }
    92. }
    93.  
     
  32. Besus

    Besus

    Joined:
    Mar 9, 2014
    Posts:
    226
    Just use the velocity.y to somehow add damage based on how high the number is. For example, you could create a new integer named "additionalFallDamage" and then control it though something like:
    Code (CSharp):
    1. if (rigidbody.velocity.y > 20 && rigidbody.velocity.y < 40)
    2.     additionalFallFamage = 2;
    3.  
    4. else if (rigidbody.velocity.y > 40 && rigidbody.velocity.y < 60)
    5.     additionalFallDamage = 4;
    And so on...

    I'm sure there may be some more fancy math that you could perform here to directly equate the rigidbody velocity to a specific value for additional fall damage but I'm not good enough with math to come up with something like that. :confused:
     
  33. Wonkee

    Wonkee

    Joined:
    Jan 7, 2014
    Posts:
    13
    Thanks
     
  34. Bentlman1981

    Bentlman1981

    Joined:
    Jun 24, 2014
    Posts:
    9
    Hello, when I replace the enemy with my own character the Animation controller goes very fast between running and idle repeatedly instead of just running while chasing the player. Do I have something set up incorrectly?
     
  35. Besus

    Besus

    Joined:
    Mar 9, 2014
    Posts:
    226
    Probably not because it sounds like the EnemyAI/TriggerParent script is jumping between the colliding states causing the "Moving" bool to toggle on and off in the enemy animation controller.I posted a fix for this earlier in this thread: http://forum.unity3d.com/threads/released-complete-physics-platformer-kit.203279/page-9#post-1735625
     
  36. eiVix

    eiVix

    Joined:
    Dec 3, 2012
    Posts:
    29
    Hi Everyone,

    Does this package work with Playmaker?
     
    Last edited: Dec 6, 2014
  37. Besus

    Besus

    Joined:
    Mar 9, 2014
    Posts:
    226
    Small preview of one of the items I'll be covering in my next video dev blog - a "crushing system" that affects all rigidbodies that are caught beneath it. This could make for some fun traps and obstacles that you can also use against enemies. :)

     
  38. DanielSnd

    DanielSnd

    Joined:
    Sep 4, 2013
    Posts:
    382
    Nice XD
    If anyone is interested in something like that, it's possible to make it by adjusting variables on my Hazard Helper script
     
  39. Besus

    Besus

    Joined:
    Mar 9, 2014
    Posts:
    226
    I took a completely different approach since I forgot you even made a script like that. :confused:

    I manually animated the movement itself but had to use some scripting trickery to get it to work as intended. The biggest obstacle in creating that was working it so the player would be crushed by it but would not take any damage from just touching or colliding with it. I accomplished this by using a "base" area to detect when a rigidbody (with a Health script) was beneath it and then carried out the effect of the collision itself when the "crusher" touched said object.

    This was one case where Unity Answers/Forums didn't really help me any. :(
     
  40. Brutusomega

    Brutusomega

    Joined:
    Jul 30, 2013
    Posts:
    56
    Is anyone using Control freak virtual joystick with this kit?I need help setting up the buttons that rotate the camera, everything else works except for this.
     
  41. sbsimosb

    sbsimosb

    Joined:
    Dec 13, 2014
    Posts:
    12
    hi, this asset is very good :) but I would ask how increase the jump based on the speed of fall ?
     
  42. Besus

    Besus

    Joined:
    Mar 9, 2014
    Posts:
    226
    How would that even work...? :confused:
    If you're falling, you certainly wouldn't be able to jump. You'll need to elaborate on what you are trying to accomplish here.
     
  43. magique

    magique

    Joined:
    May 2, 2014
    Posts:
    4,030
    Is there a proper solution for the issue of sliding on Unity terrain? Even on the very slightest of slopes, the player will slide slowly. I tried one solution offered here, but it didn't work at all. One thing that works almost all the time is to put the rigidbody to sleep right after setting the velocity to zero in the slope checks. However, this is obviously a bad solution as the rigidbody is now dead to collisions. Once you move again then all is well again, but this is obviously a bad fix. I tried all kinds of things with making the physic material have static friction, adding friction to the terrain, etc. Nothing seems to work. Oddly enough, adding a static friction to the frictionless material makes the character stutter and struggle to walk on terrain, but when no longer moving it with the joystick, it still has no problem sliding down even the slightest of slopes.
     
  44. sbsimosb

    sbsimosb

    Joined:
    Dec 13, 2014
    Posts:
    12
    For example, my character falls from a height of 10 meters on a trampoline, bouncing receives an upward thrust proportional to the height from which it has fallen. If the character had fallen by 20 meters, it would have received a double boost compared to the previous fall.
    I explained well ? (sorry for my english)
     
    Last edited: Dec 26, 2014
  45. sbsimosb

    sbsimosb

    Joined:
    Dec 13, 2014
    Posts:
    12
    Hey guy, i found in internet an example of what I would do

    Can help me with the script please ?
     
  46. Besus

    Besus

    Joined:
    Mar 9, 2014
    Posts:
    226
    I think this is just a caveat of the physics system in Unity. The only way I could prevent this was to turn off gravity or make the rigidbody kinematic (similar to putting it to sleep but retains the collisions). The problem with this was that the movement and rotation felt "funny" and I had to add a lot of code to turn gravity on/disable kinematic when the player jumped/moved/etc. As you mentioned even playing with friction values does little to help (in-fact often doing nothing at all).

    Short of adding all sorts of checks for the slope of the terrain and adjusting turning gravity on and off throughout, I think we're stuck with this so long as the scene is using gravity. :(
     
  47. magique

    magique

    Joined:
    May 2, 2014
    Posts:
    4,030
    Thanks for the tip, Besus. That actually helped me fix this fairly easily. Here is what I am doing now and it seems to work in all cases so far:

    1. Turn the player's rigidbody gravity off in PlayerMove::OnCollisionStay when we set velocity to zero.
    2. Turn the player's rigidbody gravity on in the PlayerMove::Jump function
    3. In CharacterMotor::MoveTo, I turn the player rigidbody gravity back on when the AddForce is called.

    Works great now. Thanks for the help.
     
  48. wolfomat

    wolfomat

    Joined:
    Oct 19, 2014
    Posts:
    24
    Hi there,

    i want to use the platformer as FPS control, which is currently working with W A S D (forward, backward, sidestep left, sidestep right).
    then i checked the "free mouselook" checkbox, but it wont work: neither in preview nor in the compiled one.

    do i miss something? greetings.
     

    Attached Files:

  49. BuckeyeStudios

    BuckeyeStudios

    Joined:
    Oct 24, 2013
    Posts:
    104
    kit looks nice has anyone used NGUI with it and is it ez to convert to NGUI
     
  50. Besus

    Besus

    Joined:
    Mar 9, 2014
    Posts:
    226
    1. Yes.
    2. Convert from what?