Search Unity

  1. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice

[RELEASED] Complete Physics Platformer Kit

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

  1. Riff-Rex

    Riff-Rex

    Joined:
    Mar 14, 2014
    Posts:
    15
    So after solving the problem of variable jump heights (whilst still allowing for consecutive jump boosts and double jumping!) I'm tackling another character control issue.

    I want the character to have acceleration/deceleration like Mario 64 so that running full speed in one direction and quickly turning to run the opposite way seriously cuts his momentum and he almost runs in place for a second.

    I've messed around with the acceleration settings that are already built in...turning down the deceleration does get me closer to the sense of continued momentum I want when running, but it affects the character's "friction" too much upon stopping and it slides around. I can't seem to strike a balance...

    Does anyone have any advice? Thanks!
     
  2. Besus

    Besus

    Joined:
    Mar 9, 2014
    Posts:
    226
    I recently tried tackling that as well when I Was trying to recreate an icy surface and felt as though the existing movement system would need to be entirely rewritten to make it work as I hoped. The closest that I could come was to create a trigger zone and apply a force in the existing direction which they were moving but even then it only applied if they stopped all movement; not if they reversed direction.

    The only logic I could see working with this system would be to somehow hold the current direction and if reversed, keeping a bit of momentum in their direction of travel for 'x' number of milliseconds until actually changing direction.

    Needless to say this isn't something that I wanted to tackle. :cool:
     
  3. Riff-Rex

    Riff-Rex

    Joined:
    Mar 14, 2014
    Posts:
    15
    That's what I was thinking too...I just have no idea how to go about it!

    By the way, what you've done with this kit is really impressive Besus. Cheers
     
  4. Stokes

    Stokes

    Joined:
    Aug 26, 2014
    Posts:
    2
    Has anyone had any luck modifying the CharacterMotor script so that it is compatible with Rigidbody2D?
     
  5. Brutusomega

    Brutusomega

    Joined:
    Jul 30, 2013
    Posts:
    56
    Im struggling to implement turning corners in the 2.5d sidescroller, has anyone achieved this or has any advice for me?
     
  6. DanielSnd

    DanielSnd

    Joined:
    Sep 4, 2013
    Posts:
    360
    I tried D: a lot, gave up.
    My advice is: give up
    xD
     
  7. pouria77

    pouria77

    Joined:
    Aug 13, 2014
    Posts:
    13
    Hi everyone

    I'm new to unity and am building a game using this pack and I'm using the characters from another pack, "Toon Character Pack" to replace the cube.

    I've replace the character and animations and she moves and jumps but I have a problem: she always appears a few inches above ground. I noticed that the Box Collider is repositioned when I run the game and it becomes a little lower so half of it is under the player! I position it perfectly in design time but when I run it moves.

    Any idea how I can fix this?

    Thanks

    Edit: I noticed that when I turn of the animation Controller it's fixed and the player is perfectly inthe center of the collider. No animation though ofcourse.
     
    Last edited: Aug 31, 2014
  8. pouria77

    pouria77

    Joined:
    Aug 13, 2014
    Posts:
    13
    ok I solved my previous problem by moving the collider slightly above the center, so in design time it's not perfectly alligned but in runtime it is!

    I have another small issue now. if I play too much with the big boxes, like pushing them and puling them a lot, they make the player move in the z direction and thus, falling off of the edge! although the "apply root animation" is not checked in my animation controller, this happens. But not in normal running or walking, only when interacting with boxes.
    I have no clue why. anyone can guide me on this?

    Thanks a lot
     
    Last edited: Aug 31, 2014
  9. elizeusz

    elizeusz

    Joined:
    May 2, 2012
    Posts:
    49
    Hello :) I have spawn system in the game and i try to spawn enemies from this kit but i get error :
    NullReferenceException: Object reference not set to an instance of an object
    EnemyAI.Update () (at Assets/Physics Platformer Kit/Scripts/EnemyAI.cs:69)

    Maybe somebody had this before or maybe somebody will know what i need to do to repair this ? :)
     
  10. Besus

    Besus

    Joined:
    Mar 9, 2014
    Posts:
    226
    Given the error is being reported for the following line (assuming you haven't modified the EnemyAI script):

    Code (CSharp):
    1. characterMotor.MoveTo (sightTrigger.hitObject.transform.position, acceleration, chaseStopDistance, ignoreY);
    It sounds like the script exists on something that is unable to move or is missing a sight/attack trigger. If your enemy spawner is just instantiating an enemy prefab after a set amount of time, I see no way of how that could result in the NullReferenceException in the Enemy MoveTo line of the script.

    What does your spawner code look like?
     
  11. elizeusz

    elizeusz

    Joined:
    May 2, 2012
    Posts:
    49
    I read Your explanation and i checked again all my prefabs and Yes one from them did not have Aniamtor on it. Thank You :)
     
  12. Besus

    Besus

    Joined:
    Mar 9, 2014
    Posts:
    226
    To anyone interested, volume 5 of my video development blog for my game using this kit can be found here:

     
    ArloR likes this.
  13. Camtrack

    Camtrack

    Joined:
    Jan 1, 2013
    Posts:
    27
    I was searching on the thread and I didnt find a solution for walk up small steps like character controller

    is there any solution ?

    Thanks
     
  14. Besus

    Besus

    Joined:
    Mar 9, 2014
    Posts:
    226
    Changing the main collider on the Player object to either a sphere or capsule collider (anything with a rounded bottom) should smooth it out enough to allow it to just glide over the stairs (assuming that they are shallow enough). Otherwise you would likely just need to create a slope (or custom collider shape) running on top of the staircase in place of having each of the individual stairs collide with the player.
     
  15. Camtrack

    Camtrack

    Joined:
    Jan 1, 2013
    Posts:
    27
    Thanks Besus

    I have tryed those methods

    change the shape makes the player needs a minimun velocity to get up the step..

    slope seems to be a better solution , but means to add new collider on every step on the scene...

    on the otherway I have test a solution that moves the player the necesary on y checking the floorcheckers distance of every one , this seems to work , but this dont get a smooth movent ... (and does not work with leerp)
     
    Last edited: Sep 12, 2014
  16. AkiLap

    AkiLap

    Joined:
    Sep 14, 2014
    Posts:
    24
    Thanks for this great asset!

    I'm using Control Freak with Complete Physics Platformer Kit.

    I'm trying to implement the following:
    - Pinch anywhere on screen to zoom/unzoom camera from player
    - Rotate camera around player vertically/horizontally by dragging one finger on screen (right half)

    I'm sure someone knows how to integrate this functionality.
     
  17. Besus

    Besus

    Joined:
    Mar 9, 2014
    Posts:
    226
    I'm not familiar with Control Freak since I don't target mobile however this could easily be accomplished by mapping the pinch functionality to change the "targetOffset" Vector3 in the CameraOffet script. For the rotation, the same could be done to control the "CamHorizontal" input already configured in the CameraOffset script; it's all just a matter of how this would be integrated to work with Control Freak.
     
  18. AkiLap

    AkiLap

    Joined:
    Sep 14, 2014
    Posts:
    24
    Thanks Besus,
    helped me alot!

    - For rotation I added a new stick and locked it to X-axis only, then added Enable GetAxis -> Horz axis: CamHorizontal
    - For pinch motion I added this code at targetOffset setting:
    Code (CSharp):
    1. float screenPinchAbsScale = screenZone.GetPinchScale();
    2. distance = minTargetDistance + (screenPinchAbsScale * 0.5f * (maxTargetDistance-minTargetDistance));
    3. distance = Mathf.Clamp(distance, minTargetDistance, maxTargetDistance);
    4. targetOffset.z = distance;
    It's probably not the best way to do this but it seems to do the job :)
     
  19. BokuDev

    BokuDev

    Joined:
    Jan 2, 2014
    Posts:
    81
    Changes to the AI
    Here is some examples of the physics platformer kit's AI being changed/added onto and moded. :)

    Teleporting/Phasing enemy.

    So proud to get a phasing programming done, and working for my game. It's basically inspired by bioshock infinite's crow phasing enemies.

    http://i.gyazo.com/ecd2bd23d299fcd3894251a0db49a59f.mp4

    Slime cut smaller and smaller and finally into a ton of tiny slimes.
    ^
    http://i.gyazo.com/e59ba908be70dc6fabcb082de9d04085.mp4

    Ghosts respawning until you kill an object.
    ^

    http://i.gyazo.com/f2f397fc226ac2373bb6eb69333ab062.mp4

    Ghosts ShapeShifting.
    These ghosts shape shift into copies of the knights.

    http://i.gyazo.com/ae8b1d8289bcea04871565f9692a67cd.mp4





    Pretty bad-ass what you can do with the AI with some modifications in this kit! Anyone else changing up the AI to do some cool stuff? I think I will keep updating this post with some of the cool abilities iv added to them soon! ;)
     
    Last edited: Sep 17, 2014
  20. Besus

    Besus

    Joined:
    Mar 9, 2014
    Posts:
    226
    I've made a few modifications to the EnemyAI script at this point. I added a "Special Ability" enum to the script so that I can assign unique behaviors to different enemies. One will shoot projectiles (both homing and straight at the player), one will quickly charge at the player after 'x' seconds (with them changing color as they're "charging up" to let the player know when to expect it), and the last is similar to your phasing whereby the enemy will turn invisible (or change in to whatever game object is assigned for them to turn in to) and immune when attacked, then move to a random location (defined by a random range) and then "phase" back in. Still considering some other abilities to add but those are the 3 that I've implemented in the meantime. I'll be covering these in my next video dev blog too. :cool:
     
    BokuDev likes this.
  21. Fowi

    Fowi

    Joined:
    Dec 2, 2013
    Posts:
    30
    DanielSnd, thanks for your share of the addons, but one, the HazardHelper, isn't working when the player remains unmoving on top of the Hazard... Only works if the player is moving just when the hazard collide with the player. -_-.
     
    Last edited: Sep 21, 2014
  22. Mad_Fox

    Mad_Fox

    Joined:
    May 27, 2013
    Posts:
    49
    Hi, anyone can share me a tip or something, im having issues with my character sliding in a terrain (unity terrain), im happy with how the character moves and the speeds, my problem is only that when i stand still the character always slowly moves even in tiny slopes, this is the character setup: http://gyazo.com/d623c93e5de39373d0f4db1694e4e4e7
    Thanks!
     
  23. Besus

    Besus

    Joined:
    Mar 9, 2014
    Posts:
    226
    Since you already have the slide amount set to 0, I would recommend changing the frictionless physics material (or better yet, creating a new one) and then try assigning a value of say, 5 to the static friction (leave everything else at 0) and apply that to your player collider. That should allow them to continue moving without "drag" but when standing still, should keep them in place (assuming the slope is not too steep).
     
  24. Mad_Fox

    Mad_Fox

    Joined:
    May 27, 2013
    Posts:
    49
    Thanks Besus, but its almost the same, i tried making a physics material for the player and for the terrain (its a default unity terrain), but with no success

    edit: i've solved the problem constraining Y when the character should be still (after the slope check)
     
    Last edited: Oct 3, 2014
  25. Mad_Fox

    Mad_Fox

    Joined:
    May 27, 2013
    Posts:
    49
    im still cant make it, im thinking, maybe making a script that if velocity if < something the script stop the character? it's this viable?

    edit: i've solved the problem constraining Y when the character should be still (after the slope check)
     
    Last edited: Oct 3, 2014
  26. Besus

    Besus

    Joined:
    Mar 9, 2014
    Posts:
    226
    Within the IsGrounded() block of code, you could add an if statement just below the slope float calculation (slope = Vector3.Angle (hit.normal, Vector3.up);) with something like:

    Code (CSharp):
    1. if (characterMotor.DistanceToTarget < 0.1f && slope < slopeLimit)
    2. rigidbody.velocity = new Vector3 (0f, 0f, 0f);
    It's a bit crude, but in theory it should work (when the player is not moving).
     
  27. outtoplay

    outtoplay

    Joined:
    Apr 29, 2009
    Posts:
    741
    Might there be a way to do a 'sking' type mechanic? Something like a 2.5d sidescroller where a snowboarding or sking character could accelerate on touch (or click), and stay oriented to slopes and hill, maybe take some jumps?

    Greg eluded that the option could be set up but that was long ago and never mentioned how. Shame he abandoned the product and his customers. But props to Daniel, Brandon and others for keeping this asset kickin'
     
  28. will_brett

    will_brett

    Joined:
    Feb 16, 2013
    Posts:
    208
    Hey there, This package is fantastic. I do have a question though. I have made a moving platform for my character to get across a gap. However when the character is on the platform the character does not move with it and ends up sliding off. Couldn't see any differences between my set up and the lava platform in the demo.
     
  29. will_brett

    will_brett

    Joined:
    Feb 16, 2013
    Posts:
    208
    Ignore that. Found the tag :D
     
  30. Brutusomega

    Brutusomega

    Joined:
    Jul 30, 2013
    Posts:
    56
    Has anyone tried to implement super mario galaxy style faux gravity (walk on spheres without falling down)?
    I stumbled upon the locomotion system https://www.assetstore.unity3d.com/en/#!/content/7135 and it allows you to do this (see the planet walk scene) and i wonder if someone who is good at programming can implement this in the complete physics kit.
     
  31. Besus

    Besus

    Joined:
    Mar 9, 2014
    Posts:
    226
    I had actually implemented this so that the player would "follow" hills more closely; it's pretty much just using a Raycast to find the hit.normal of the surface and then aligning the player transform.up to it. It seemed to work fine but I wound up moving away from it because it didn't make sense to conform to slopes that were less than my slope slide max. Anyway, there are plenty of tutorials and tips on doing this with some searching. For example:

    http://forum.unity3d.com/threads/faux-gravity-tutorial-walk-on-planets-like-mario-galaxy.222215/

    http://forum.unity3d.com/threads/super-mario-galaxy-gravity.122385/

    Edit: To add to this, I believe I wound-up putting the code in the IsGrounded() statement so that the player would only align while walking. If the planets are smaller though it would make more sense to put that in an update statement with a longer distance on the Raycast so that the player conforms to the planet even while jumping/falling. Limiting the Raycast to only hit certain layers namely ground) would likely be the best way to go here so that the player isn't conforming to obstacles and other things that get in the way.
     
  32. pushingpandas

    pushingpandas

    Joined:
    Jan 12, 2013
    Posts:
    1,403
    Hello, can anybody please make a simple video tutorial how to get the kit running in my own scene? Which prefabs do I need to implement? The PDF documentation is a littlebit - unclear regading that. thank you very much!

    Oh and a tutorial how to change character :D would be awesome
     
  33. ArloR

    ArloR

    Joined:
    Feb 22, 2014
    Posts:
    10
    The Author is created 3 great videos that start from a fresh brand new scene. They can be seen on his YouTube channel here

    https://www.youtube.com/channel/UCyn_t7dt2cM1sKt49ETBlxA

    I hope he creates a few more. Changing the character would be cool . I hope one is also created to better explain creating platform movers.
     
  34. ArloR

    ArloR

    Joined:
    Feb 22, 2014
    Posts:
    10
    looking for a good YouTube tutorial on the "moving platform" script for the Physics Platformer Asset. The author did a great job explaining most of the scripts with his YouTube channel but the moving platform script was not covered. Hope he or perhaps someone else viewing this thread is up to the challenge of creating a short narrated YouTube tutorial video that concisely goes through the steps of getting this task (script) up and running? Thanks from a Unity Noob.
     
  35. pushingpandas

    pushingpandas

    Joined:
    Jan 12, 2013
    Posts:
    1,403
    great thanks!
     
  36. Andreas Busk

    Andreas Busk

    Joined:
    Mar 21, 2014
    Posts:
    25
    In all scenes with this otherwise excellent kit - I have a problem!

    When I press play and enter the scene I hear all the sounds as if they where set to 'play on awake'!

    Please help!

    Best,

    Andreas
     
  37. pushingpandas

    pushingpandas

    Joined:
    Jan 12, 2013
    Posts:
    1,403
  38. pushingpandas

    pushingpandas

    Joined:
    Jan 12, 2013
    Posts:
    1,403
    How can I create a frictionless material? I have a landscape but my player is sliding it down. I don't want this kind of gliding. How to remove that? Thank you!
     
  39. will_brett

    will_brett

    Joined:
    Feb 16, 2013
    Posts:
    208
    Has anyone tried implementing ledge grabbing, climbing and traversing along a ledge? Its something would be really useful in this kit so if you have please share or hint at how you did it? Would love to give it a go
     
  40. will_brett

    will_brett

    Joined:
    Feb 16, 2013
    Posts:
    208
    So i've nearly got ledge grabbing to work. Just need to get the traversing along an edge to work now. Will share the script when i've done it.

    If anyone knows how to make character strafe that would save me a lot of time.
     
    pixxelbob likes this.
  41. pixxelbob

    pixxelbob

    Joined:
    Aug 26, 2014
    Posts:
    111
    This is a wonderful little kit. Really helps getting started with a platformer, and such a reasonable price. Thanks.
    I have been running the demos I noticed a little issue with moving platforms, specifically those that move horizontally.

    The character slides on the platform when the platform changes direction abruptly.
    If the player is near the edge of the platform it falls off.
    We all have the demo scenes but for completeness here's a video illustrating the issue.



    I suspect the problem lies in the PlayerMove script in the IsGrounded method.
    I was just wondering if anyone has come up with a solution?
    Thanks in advance for your help!
     
  42. Auto-Bot

    Auto-Bot

    Joined:
    Feb 6, 2014
    Posts:
    283
    Is there a specific touch input kit for mobile that will work easily with this? And if so, can some one point me towards a guide?
     
  43. will_brett

    will_brett

    Joined:
    Feb 16, 2013
    Posts:
    208
    I think any touch kit that works with Unity's built in inputManager should be fine but I havent tested this so can not be sure. But the PlayerMove script in this kit uses the InputManager. Im also planning on trying this later in development so will post back what I used and what problems there were if any
     
  44. will_brett

    will_brett

    Joined:
    Feb 16, 2013
    Posts:
    208
    So here is a video showing the ledge grabbing so far. Iv just duplicated the carry animation for this ready for a climb animation. Unfortunate I haven't got traversing along the ledge working yet and I also want the character to lerp to a position on the ledge so that if he's on top and walks off he will grab the ledge and not just float.

    Its also important to note that I have used parts of DanielSND's ladder script in this script.

    Feel free to comment, criticize or even help improve it. Also if anyone wants the script in its current form let me know.

     
  45. Auto-Bot

    Auto-Bot

    Joined:
    Feb 6, 2014
    Posts:
    283
    As someone who doesn't particularly know much about the input manager, would it be as simple as linking to the right key or would I likely need to edit the scripts. I noticed on page 2 someone suggested Virtual Control Suite, but it required modifying PlayerMove and Throwing scripts.
     
  46. will_brett

    will_brett

    Joined:
    Feb 16, 2013
    Posts:
    208
    If I get chance after work tomorrow I will take a look as I know its something I want to do. If there are script changes I do a tutorial :D
     
    Auto-Bot likes this.
  47. Auto-Bot

    Auto-Bot

    Joined:
    Feb 6, 2014
    Posts:
    283
    Cheers, Will_Brett! :)

    Also, few pieces of note here:

    https://vid.me/3u3 (I think this video might still be converting, as I can't get it to run).

    Not too sure why my animations aren't playing. I've got Idle, Run, Jump & Fall anims set (not the arms ones though, not really sure what I'm supposed to do in that area). It just stands in it's model post, as you can see in the vid.
    Boom, fixed this too!

    Also, my health goes down below 0 with the replaced model. I hit in minus -1, -2, etc.

    Fixed this, didn't have my flash object set.

    And lastly, why does my model spin when holding something? Did that with the original model too.
     
    Last edited: Oct 2, 2014
  48. hellobard

    hellobard

    Joined:
    Sep 26, 2012
    Posts:
    133
    great kit, really loving it, but I was wondering. Is it not possible to jump while you're sliding?
     
  49. Besus

    Besus

    Joined:
    Mar 9, 2014
    Posts:
    226
    Nope, because technically you are not grounded while sliding. You could rework the if statement for the jumping mechanics to allow you to do so though; but you would obviously want to use some bool (or prerequisite) to prevent the player from jumping all the time.
     
  50. Yog-Shoggoth

    Yog-Shoggoth

    Joined:
    Mar 23, 2013
    Posts:
    13
    Picked the kit up while it was on sale and I've been tinkering with it trying to implement a wall-kick similar to the one demonstrated by Besus.

    Taking DanielSnd's walljump script as a basis, I've managed to hack something together using Google and Unity Answers which works fine when you hit the wall straight on. However I'm struggling to handle hitting walls at an angle.

    My implementation uses a RayCast from the player to detect the wall object and then uses Vector3.Reflect on the hit.normal generated from that raycast to provide the direction in which to rotate the player about before applying a forward force to bounce the player back off the wall.

    However when I try to wall kick/jump at an angle I'm getting the error:

    Look rotation viewing vector is zero
    UnityEngine.Quaternion:LookRotation(Vector3)


    My hacked together/poorly written code is below. Anyone got any hints as to where I'm going wrong?

    Code (CSharp):
    1. using UnityEngine;
    2. using System.Collections;
    3.  
    4. public class PlayerWallJump : MonoBehaviour {
    5.    
    6.     //We'll use those 3 to communicate with the rest of the kit.
    7.     private PlayerMove playerMove;
    8.     private CharacterMotor characterMotor;
    9.    
    10.     public bool CanWallJump;
    11.     public bool HasWallJumped;
    12.  
    13.     //We'll pick the grounded bool from the Animator and store here to know if we're grounded.
    14.     public bool GroundedBool;
    15.  
    16.     // Use this for initialization
    17.     void Start () {
    18.         playerMove = GetComponent<PlayerMove>();
    19.         characterMotor = GetComponent<CharacterMotor>();
    20.         CanWallJump=false;
    21.     }
    22.    
    23.     void Update() {
    24.  
    25.         //if (!CanWallJump){
    26.         //    return;
    27.         //}
    28.  
    29.         Debug.DrawRay(playerMove.transform.position, playerMove.transform.forward, Color.red);
    30.  
    31.         if (CanWallJump && Input.GetButtonDown ("Jump") ) {
    32.  
    33.             Ray wallCheck = new Ray (playerMove.transform.position, playerMove.transform.forward);
    34.             RaycastHit wallHit;
    35.  
    36.             Physics.Raycast(wallCheck, out wallHit, .5f);
    37.  
    38.             Debug.Log(wallHit);
    39.  
    40.             if (!HasWallJumped) {
    41.  
    42.                 //gameObject.rigidbody.velocity = Vector3.Reflect(gameObject.rigidbody.velocity, wallHit.normal);
    43.                 gameObject.transform.rotation = Quaternion.LookRotation(wallHit.normal);
    44.                 //gameObject.transform.forward = Vector3.Reflect(gameObject.transform.forward, wallHit.normal);
    45.                 gameObject.rigidbody.AddForce(gameObject.transform.forward * 900f);
    46.                 gameObject.rigidbody.AddForce(gameObject.transform.up * 450f);
    47.                 CanWallJump = false;
    48.                 HasWallJumped = true;
    49.  
    50.             }
    51.  
    52.         }
    53.  
    54.  
    55.     }
    56.  
    57.     //This is an udpate that is called less frequently
    58.     void FixedUpdate () {
    59.         //Let's pick the Grounded Bool from the animator, since the player grounded bool is private and we can't get it directly..
    60.         GroundedBool = playerMove.animator.GetBool("Grounded");
    61.  
    62.     }
    63.  
    64.     void OnTriggerEnter(Collider other) {
    65.         if(other.gameObject.tag=="Wall" && (GroundedBool==false)) {
    66.             CanWallJump=true;
    67.  
    68.         }
    69.     }
    70.    
    71.     void OnTriggerExit(Collider other) {
    72.         if(other.gameObject.tag=="Wall") {
    73.             CanWallJump=false;
    74.             HasWallJumped=false;
    75.  
    76.         }
    77.     }
    78. }
     
unityunity