Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

[RELEASED] Complete Physics Platformer Kit

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

  1. nnichael

    nnichael

    Joined:
    Mar 13, 2013
    Posts:
    5
    I tried to switch out the character and he is able to move around but he can't jump, are there any specific things that my new character model has to have before I import him?
     
  2. Clodo

    Clodo

    Joined:
    Dec 27, 2013
    Posts:
    40
    My request for your 'most requested features' :p

    - Ability to slide over an inclinated ground.
    The player need to have a sitting position, inclinated based on ground.
    It's not a 'flying' status, jumping allowed.
    Sample Reference: http://youtu.be/kz3t_Z750yU?t=20s

    - Swim. I understand you can tweak the Water script,
    but i can't go up until i reach the ground. Maybe simple allow jumping
    without 'grounded' bool. Player swim animation?
    Sample Reference: http://www.youtube.com/watch?v=bUjTB2HVGac

    - I need to study further, but seems that player don't have any analog movement,
    like run if my virtual axis is 1 or simply walk if is 0.5.

    - Why Player 'Third Jump Force' have Z=7 in your demo?

    Just my cents. Sorry for my english :p

    Thanks for your great, great work!
     
  3. Wonkee

    Wonkee

    Joined:
    Jan 7, 2014
    Posts:
    13
    I'm new to Unity and game development in general.

    That said, I've been working with this kit for the past few days and love it. I'm just having all sorts of issues figuring out how to add to it.

    Problem 1- I purchased another character with animations to use for the enemy instead of sliding cubes. The animations seem to have been made differently than the player model included in the kit. I added the new enemy character and added all the components the kit's prefab enemy had and got the new model to slide around a bit, but it ultimately didn't work and the model ended up falling through the map.

    I then went through a few tutorials trying to get this new enemy to actually work, but every tutorial uses a completely different method for every aspect which made it impossible for me to get working. I managed to write a basic script to get the model to slide around and follow the player, but the way the animations are on the kit's player character are not at all like the enemy character I got off of the asset store. Instead of all the animations being on the model, there are 11 different fbx files and I haven't a clue how to get those animations to play on the enemy.

    Anyway, I'm really confused and frustrated at this point and have no idea what I should be doing. Tutorials at this point have just served to further frustrate me because the title seems like it would explain what I need to know then has nothing to do with what I'm trying to do.

    Help?
     
  4. Clodo

    Clodo

    Joined:
    Dec 27, 2013
    Posts:
    40
    In EnemyAI.cs,
    Code (csharp):
    1.  
    2. Vector3 bounceMultiplier = new Vector3(0f, 1.5f, 0f) * playerMove.onEnemyBounce;
    3. playerMove.Jump (bounceForce + bounceMultiplier);
    4.  
    add an 'if', so:
    Code (csharp):
    1.  
    2. Vector3 bounceMultiplier = new Vector3(0f, 1.5f, 0f) * playerMove.onEnemyBounce;
    3. if(bounceForce != Vector3.zero)
    4.     playerMove.Jump (bounceForce + bounceMultiplier);
    5.  
    .

    If i want a kind of enemy that don't hurt, and i want simply to stay on us, don't use the 'Health' component, and i set 'Bounce Force', 'Push Force' and 'Push Height' to zero. But the player still jump over it. With the changes above works well, think about that.
     
  5. BryanO

    BryanO

    Joined:
    Jan 8, 2014
    Posts:
    186
    Can you please respond to this again with a bit more detail. I've read the PDF on the subject from your package as well but I can't seem to make this work. This is probably the single most important asset change people will want so it would help if you got pretty granular and use language specific to UNITY controller architecture that might help. While I understand the concept the specific steps required to make this happen don't yield an animated avatar for me that works correctly. I get a model that drifts away from the camera when it moves when I drop it onto the player object and remove the default "cube" player model and it's bones.
     
  6. pushingpandas

    pushingpandas

    Joined:
    Jan 12, 2013
    Posts:
    1,419
    When will the promised video tutorials coming out? Thanks
     
  7. EddieChristian

    EddieChristian

    Joined:
    Oct 9, 2012
    Posts:
    725
    I just noticed, in the demo scene if you are slipping on a ramp as you try to run up it, the Jump function doesn't work. Thought I would post it in case it is a bug.
     
  8. RyuMaster

    RyuMaster

    Joined:
    Sep 13, 2010
    Posts:
    468
    Hi! There is transformation for the camera inside the script. Is it actually hard to make it work with the first-person-camera, i.e., will I only need to alter some rotation routine inside the original script, or there is more going on behind the scene?
     
  9. Greg-Sergeant

    Greg-Sergeant

    Joined:
    Feb 18, 2011
    Posts:
    76
    This is AWESOME!! Thanks for sharing, i love seeing what everyone's up to with the kit.



    Thank YOU, for sharing such great work and level design - i'm really enjoying seeing this project come together.

    Take a look inside the GUIManager script. There are a few simple lines which will resemble: GUILayout.Label("write this");
    If you change the "write this" parts, you'll change what it writes, and you can also add your own things! Simple huh?

    The "Throwing" script should only be attached to the player. Assign the tag: "pickup" to ANY RIGIDBODY YOU WANT and the player will then be able to lift and throw it! Inside the guidebook there's simple explanations for what each script does.

    I assume he can't jump because either: your jump force variable is 0,0,0 OR your ground checks are not set up properly - so the system thinks the player is not on the ground, and shouldn't be able to jump yet, so check those things.

    If you jump, and when you land tap jump again quickly, and then do that a third time you'll notice the player jumps FORWARD a bit (7 force in Z axis) on that 3rd consecutive jump - just like in Mario 64! (see guidebook for variable and script explanations). Thanks for the tip about the bounce force!

    Make sure "root motion" is unchecked on the animation. Also, inquire about this with the asset producer, i don't know why there would be 11 fbx files.. animation shouldn't effect the enemy characters physics or behavior at all - just change the visuals. Contact the support email if you need more help, and we'll be HAPPY TO HELP!

    I will make a video on it VERY soon! My laptop isn't powerful enough for smooth video tutorials - hence the delays - but i'm organizing to use a more powerful one, they will be worth it!

    THATS A FEATURE! You can set a slope limit which stops players jumping up it, so certain parts of your map can keep the player in bounds, or provide a slide for them to slip down :) Thanks for letting me know about it though.

    The camera script:
    1. Follows the player how you want it to
    2. Avoids clipping walls
    3. Applies a water-filter when you're underwater
    4. Can allow you to control the camera with keyboard or mouse

    You can set the camera to "lock" to the players rotation (new in 1.4 update!), and you set the cameras position to be where the players eyes are. So you could achieve a first person camera simply with that! However if you want a mouse look, i would simply parent the "first person camera" component to the player and use that one instead. The assets are interchangeable for modular design!



    I forgot to mention.. the 1.4 update is out now!!
    New features include:
    - added camera control (mouse based, follow behind..)
    - added enemy AI tools (custom patrol routes)
    - improved camera avoidance (with custom tag filters)
    - improved documentation and performance
    - the groundwork for iOS controls which will arrive shortly!


    Did i mention we're still the #1 asset in our category? We also have over 50 FIVE STAR reviews. Thankyou so much for the support everyone, it is really great to have such a thriving community of developers with a re-invigorated interest in platform games within the Unity community! Having seen some of the fantastic work created with this kit i can already say it was worth it, and i'm excited to discover what you make next!
     
    Last edited: Jan 15, 2014
  10. Clodo

    Clodo

    Joined:
    Dec 27, 2013
    Posts:
    40
    Feature request: Smash Death
    Reference: http://youtu.be/RcdpmAHUkWw?t=1m21s

    Maybe not simple: think about a cube A behind player, and a moving cube B in front of the player (z axis).
    When B collide with player, must 'push' the player, until collide also with the behind cube A.
    At that point, death, and the player start scaling on the same axis of the force that come from the moving cube.
    The player scaling is not only a visual feedback: currently the player is throwed away by physics, and need to maintain position also during the death gui feedback.
     
  11. hensoup

    hensoup

    Joined:
    Jan 13, 2014
    Posts:
    35
    http://www.hensoupstudios.com/pekebuild.html

    made a example of doing "Sonic" style Roll attack. both on ground and on air WIP the demo is a example of the attack module I will be doing a full game demo soon as I add more to your base. I replaced the health percentage with a heart bars. kinid of cruddy at the moment.

    WASD keys to move Shift to Roll or Grab and Space to jump.
    '

    this is a great platform engine you did and I'm adding many features to it.
     
    Last edited: Jan 15, 2014
  12. Wonkee

    Wonkee

    Joined:
    Jan 7, 2014
    Posts:
    13
    When the play grabs onto a fixed rotating object- in my case its a pipe valve- as the player goes around he loses his grip and falls. Is there a way I can have the player stay attached to the valve as it rotates?

    http://host.vindicraft.com/testgame/index.html
     
    Last edited: Jan 15, 2014
  13. Wonkee

    Wonkee

    Joined:
    Jan 7, 2014
    Posts:
    13
    That roll-attack is really cool! Nice work.

    Kit could also use an ice material. Using the ice material in standard assets doesn't seem to do it. I attempted making a slide with a ramp, but the player just kinda stops in the middle.
     
    Last edited: Jan 16, 2014
  14. AllanMSmith

    AllanMSmith

    Joined:
    Oct 2, 2012
    Posts:
    180
    Hey Greg, first of all, nice kit, well done! =)

    However I have a few questions about it:

    1- I am kind of afraid of your solution for the anti-sliding on slight slope... and the character keeps sliding down the slope very slowly with this solution, which doesnt look very good. I made a small change... basically instead of velocity = 0, I set drag = 1000, or back to 0 if needed. However the solution overall doesnt seem to be very reliable to me... if something tagged hits the character or if you touch anything tagged the char will be sliding down again... Im not sure what the best solution for this would be =/

    2- I made my own version of your "PlayerMove" script, I didnt need everything you were doing but, all in all its very similar, but I've noticed you could do a few minor optimizations such as caching the transform and rigidbody and easily avoid the foreach loop... but anyway, its nothing major.

    3- Just my personal suggestion, I think that you are planning on making a complete game framework (IAs, etc etc), but I would like you even more if you focused on the char control aspect of your package =P stuff that people suggested already... swimming, wall jumping, etc etc etc... =P

    But my main concern is really the anti-sliding solution, I think it might be too susceptible to bugs =/ Anyway, gratz for the great package and I hope to see more updates from you soon =)
    Best regards,
    Allan
     
  15. Clodo

    Clodo

    Joined:
    Dec 27, 2013
    Posts:
    40
    Player -> Plater Throwing -> Holding Break Force. Try it.
     
  16. Clodo

    Clodo

    Joined:
    Dec 27, 2013
    Posts:
    40
    I obtained a good result with a simple script, attached to platform. On every frame we save the delta position from current frame and the previous frame, and move the rigidbody of the player by the same amount. Enabled/disabled by collision hit.
    Not a real physics, but playable.
     
  17. Clodo

    Clodo

    Joined:
    Dec 27, 2013
    Posts:
    40
    Another feature request for dev lists :p

    Player can 'connect' to other GameObject, and any input are redirected to that GameObject.
    Think a sledding.
    Other example: http://youtu.be/njvszLcunsk?t=28s (Always Mario, i know :p).
     
    Last edited: Jan 17, 2014
  18. Wonkee

    Wonkee

    Joined:
    Jan 7, 2014
    Posts:
    13
    I have read the readme multiple times and still cannot get MovingPlatforms to work. Specifically where it says to give the empty child objects the "Editor Only" tag- when I do so the blue spheres you mention never show up. Not sure what I'm doing wrong.

    I have got some moving platforms via animation, but the player just slides right off of them even if I give them the MovingPlatform tag.
     
  19. Clodo

    Clodo

    Joined:
    Dec 27, 2013
    Posts:
    40
    I'm using EasyTouch virtual controller for moving player.
    There is a thresold, below them the player don't move.
    There is another thresold, below them the avatar 'walk' on place but no move.
    In PlayerMove.cs there is:
    Code (csharp):
    1.  
    2. characterMotor.MoveTo(moveDirection, curAccel, 0.7f, true)
    3.  
    if i change 0.7f (stopDistance) to 0.1f, and curAccel with my accelleration (=curAccel*direction.magnitude) i obtain my objective: walk slow or fast based on virtual joystick position.
    But... under some threshold, the avatar don't walk, only force is applied, so it slide. Where is defined? in the .fbx file? If yes, what editor you use? First time with .fbx...
    Thanks for any feedback.
     
  20. AllanMSmith

    AllanMSmith

    Joined:
    Oct 2, 2012
    Posts:
    180
    Hey, also, a new question: which is the easiest way to change the movement speed of the character? Currently I am multiplying current acceleration, deceleration and max speed by the value desired (such as a slow effect, etc), is there an easier way? Not that this solution is exactly complicated but as I add more factors to the movement speed calculation I have tons of multiplications on 3 different variables to get the results im looking for...
     
  21. Greg-Sergeant

    Greg-Sergeant

    Joined:
    Feb 18, 2011
    Posts:
    76
    AWESOME! I really like that you made it lock onto enemies when attacking from the air as well.


    I LIKE TO KEEP THINGS SIMPLE. So for this i would simply create the animation for the smashers, and then also within unity animation create a 'hazard' trigger that toggles on/off where the smashers meet. That way anything caught between the smashers will be smashed! You could even use this to solve some puzzles like squashing a boss or breaking open a safe!


    First off, really great work on the game! LOOKS VERY PROFESSIONAL and those launching platforms/bounce huts are really great design! Like Clodo suggested you can adjust the 'holding break force'. I think what is actually happening is that the object is rotating on the Z axis, and the player lerps rotation to match that of the object they're holding - however, the player is only allowed to rotate on the Y axis for the most part - so he lets go. I would try going into the throwing script and change the line of code that matches rotation to meet your needs.


    Characters friction is coded into the scripts to be FULLY ADJUSTABLE AND JUST WORKS in any situation! So if you want a slide, i would write a simple script that:
    1. see's if we're standing on ice (get collision with tag)
    2. change the players 'ground deceleration' to a low number if we are


    Thanks for the feedback Allan! Preventing sliding on subtle slopes was the trickiest part of the entire kit to get right, second only to the moving platform support - the inherent difficult being how to keep the physics real and reactive to every situation - however i think whats here is the 'best' solution without either getting very complicated or opening it up to complex bugs. If you find a more elegant solution i'd be really interested to hear it!


    Please send some screenshots of what you're doing to the support email, and WE'LL FIND THE SOLUTION FOR YOU!


    Animation changes are controlled by the animator controller, you just need to open that up in the animator window and adjust the values for the animation transition into running. Simple! Check out unity docs on mechanim if you have trouble finding it.


    I would change the: acceleration, deceleration and max speed variables like you're doing. If you're game design systems are getting too complicated i would streamline the design. Could you use an invisible 'water zone' to slow the player in some areas?


    Thanks for the feedback guys, it's great to see more and more awesome games being made with the kit!
     
  22. Wonkee

    Wonkee

    Joined:
    Jan 7, 2014
    Posts:
    13
    I know I probably wouldn't have this issue if I were more experienced with Unity, but I cannot figure out how to adjust the accel and decel for the player in a script.

    I tried just putting "float accel = "20";" when the player is on an object with the "Ice" tag, but this gives compile errors "A member is already defined." I've been googling different things trying to figure out how to do this, but I cannot get a clear answer and whatever I try fails.

    Starting to get frustrated that I can't figure this out :(

    Code (csharp):
    1.  
    2. public void OnCollisionStay(Collision other)
    3. {
    4. if (other.collider.tag == "Ice")
    5. float accel = iceAccel;
    6. decel = iceDecel;
    7. }
    I know this is totally wrong, but I can't find the right way to do it.
     
    Last edited: Jan 23, 2014
  23. Greg-Sergeant

    Greg-Sergeant

    Joined:
    Feb 18, 2011
    Posts:
    76
    This is beginner C# so i would recommend taking online lessons (homeandlearn.org or unity's tutorials) before attempting it - else you're basically walking around blind in the dark, and you will bump into things!

    But here's the simplest way to achieve ice (around 2 lines of code):

    1. Inside 'Player Move' script there is a method called 'Grounded' which checks what the player is standing on and takes action on that. You'd want to add a simple check that changes a bool "onIce" to true if we're standing on an ice tagged object.

    2.There is also a line of code at the top of 'Update' which basically says: if were on the ground use the ground accel/decel, otherwise use the air accel/decel. Now you'll need to add another line which says: if we ARE grounded, check whether we are on ice, and if we are use 'ice deceleration/acceleration' (values you define) but if not, use the regular ground 'acceleration/deceleration'

    Hope that helps!
     
  24. sirius_002

    sirius_002

    Joined:
    Aug 16, 2012
    Posts:
    65
    Greg, what is coming up for this kit, any ideas for future versions?
     
  25. Wonkee

    Wonkee

    Joined:
    Jan 7, 2014
    Posts:
    13
    Invaluable help, thank you. To be honest I only have a light background with coding- mostly with the web. This is also my first attempt at creating a game with any software. Without the help of the Unity community and the asset store, I would have made little progress.

    Ice is now working! I feel so accomplished right now, lol.
     
    Last edited: Jan 24, 2014
  26. hensoup

    hensoup

    Joined:
    Jan 13, 2014
    Posts:
    35
    how could I share some of my code? for the platform attacks like pouncing and such. also working on adding buttons and other puzzlews working also on imporving the moving platform mechanic I'm enjoying this alot.
     
  27. Wonkee

    Wonkee

    Joined:
    Jan 7, 2014
    Posts:
    13
    You could use the code tag to post some of your code.
     
  28. devandart

    devandart

    Joined:
    Jun 7, 2013
    Posts:
    144
    Hi,

    do I understand right, that I only can use your package with Mecanim?
    I can not receive events or states which action is active at the moment like idle, run etc.?

    I would like to implement my own animations but they aren't done with Mecanim.

    Thanks.
     
    Last edited: Jan 24, 2014
  29. bdgbdg

    bdgbdg

    Joined:
    Jan 18, 2014
    Posts:
    2
    Any idea when the wall jumping will be done?

    Is there any support for Xbox Controller?

    Would it be easy to add a special jump when the character turns around after running? (as in Mario 64)
     
  30. rickcollette

    rickcollette

    Joined:
    Mar 17, 2013
    Posts:
    304
    Is there a simple setup tutorial? I cannot seem to get the player and camera synched.. and I am just starting with it.. I am sure there will be other issues I will need to overcome as well.
    thanks!
     
  31. Jeremy Fuller

    Jeremy Fuller

    Joined:
    Feb 20, 2013
    Posts:
    9
    I'm trying to add some extra camera control to a side-scrolling project. Greg, I'm curious what your approach would be. Basically I need to smoothly modify the camera's follow vector as the player moves into new portions of the level. The goal is to restrict the camera's height (Y axis) to between a certain range, then as you move out of that part of the level, the camera restrictions go away and it follows the player normally. In some areas of the level the camera may also need to zoom out to let the player see more of the level at once.

    I've been trying to think of the best approach here. Ideally the camera vector modifications would be declared in the editor somehow rather than via scripting. The transitions need to be smooth, but I could probably use a tweeting library for that if needed.

    One example of what I mean would be in Trine. As the player navigates through the level, the camera's follow vector changes periodically. Any thoughts?
     
  32. Wonkee

    Wonkee

    Joined:
    Jan 7, 2014
    Posts:
    13
    The main camera should have the Camera Follow script attached to it, just select the player where it says "target" and the camera with follow that.
     
  33. PDubulous

    PDubulous

    Joined:
    Apr 16, 2013
    Posts:
    5
    We've been using this for a week or two now and we are all really blown away. Implementation was a breeze and it worked very well with what we already had in place. A+ nice work. Has anyone had success using this character set up with a vanilla hinge joint? The thrown objects work great, but we crash on contact with a character. I guess I should clarify that its a box collider with a hinge joint on it.
     
    Last edited: Jan 27, 2014
  34. Greg-Sergeant

    Greg-Sergeant

    Joined:
    Feb 18, 2011
    Posts:
    76
    In order: iOS/android controls, video tutorials, walljumping
    Later on possibly: climbing, melee/shooting attacks, humanoid animations (work with any human model), swimming.. as well as general improvements to all around quality.


    Use pastebin and select the C# syntax. Would love to see what you've come up with!

    You can use any animations, as long they're specific to your model - and you can very easily get the current animation state or make your own adjustments! Mechanim is just a simple state-machine which handles animation transitions for you! You can just plug your own animations into it - or if you want the player .fbx is included (rigged) so you can open that in a 3D package to animate/edit him however you like.

    1. After iOS controls and video tutorials - can't say exactly when.
    2. I haven't looked into it, but i've heard it's very easy. Look on google for a tutorial, or ask someone here.
    3. Easy is quite a relative term haha, if you know your way around game logic i think you'd have no problem. There are already methods to track player direction, input, speed and jumping.


    Yes, in the guidebook you'll find all the guidance you'll need, take a look in the "simple demo" environment as well. For the most part you just drag a script onto an object and it sets up for you :) Advanced video tutorials coming later as well!


    The camera has a trigger on it. I would write a script along the lines of:
    - On trigger stay > if the trigger has the camera tag
    - Clamp cameras intended position* to within this trigger box

    This way in game you can just place a trigger and easily modify how the camera is controlled.

    *intended position (cant remember exact name..) is a Vector3 variable inside the camera script, which gives the camera a position to smoothly move to.
     
  35. Jeremy Fuller

    Jeremy Fuller

    Joined:
    Feb 20, 2013
    Posts:
    9
    Thanks so much for your reply -- I'll give that a shot!

    Apologies if this has been covered already. I'm really struggling with keeping the player from slipping off moving platforms. I've played with the friction values, and while it works fairly well when the platforms are going up and down, it doesn't work very well for horizontal platforms moving a little bit faster. Looking at the code, I confess I'm confused as to what it's doing there.
     
  36. hensoup

    hensoup

    Joined:
    Jan 13, 2014
    Posts:
    35
    I already got Xbox 360 controller support added I am adding jumping and shooting abilities to enemies in Greg's code. Would you like me to send you code I did for your code base Greg?
     
  37. rickcollette

    rickcollette

    Joined:
    Mar 17, 2013
    Posts:
    304
    Good - because I am having a heck of a time just getting the character to move correctly. Using a 3d asset from the asset store as a test (the Lenzo character) - I tried following the guidebook, played with the demo, just a real bad time.. other people have done what I am doing successfully, so I am pretty sure its due to my visual learning style.. when the videos come, I'll probably have a better time at it.. which is a bummer, cause I really wanna play with this...

    :)
     
  38. pioupiou75020

    pioupiou75020

    Joined:
    Jan 30, 2014
    Posts:
    1
    Hello,

    Above all congratulations for your work, this kit is great.
    I'm new to unity, and that starting in development.
    I found that the "player" reload in the scene when he dies. I wonder what I should put in the script "Health" (I guess), so that the player reload another level.

    Thank you for your help and congratulations.
     
  39. someunityguy

    someunityguy

    Joined:
    Jun 28, 2011
    Posts:
    35
    These are not the droids you are looking for..............
     
    Last edited: Jan 31, 2014
  40. Jeremy Fuller

    Jeremy Fuller

    Joined:
    Feb 20, 2013
    Posts:
    9
    Brilliant solution! Here is my modified function from PlayerMove.cs:

    Code (csharp):
    1.     void OnCollisionStay(Collision other)
    2.     {
    3.         //only stop movement on slight slopes if we aren't being touched by anything else
    4.         if (other.collider.tag != "Untagged" || grounded == false)
    5.             return;
    6.         //if no movement should be happening, stop player moving in Z/X axis
    7.         if(direction.magnitude == 0  slope < slopeLimit  rigidbody.velocity.magnitude < 2)
    8.         {
    9.             //it's usually not a good idea to alter a rigidbodies velocity every frame
    10.             //but this is the cleanest way i could think of, and we have a lot of checks beforehand, so it shou
    11.             rigidbody.velocity = Vector3.zero;
    12.             rigidbody.drag = 1000;
    13.         }
    14.         else rigidbody.drag = 0;
    15.     }
    This does appear to stop all sliding down minor slopes. This is one of those things that's totally broken in the package, there's really never any case where you should be sliding like you do on slopes that you are otherwise allowed to walk up. Further testing will tell if this really is the magic fix, but so far it seems to work. Note that I also left the velocity change in.

    Edit: Whoops, this doesn't let you jump in place (you can jump while moving). To allow jumping while in place, alter the JumpCalculations() function in PlayerMove.cs to set rigidbody.drag = 0 just before the three calls to Jump(). I also set rigidbody.drag = 0 inside the Slope Control section within the IsGrounded() function. This should theoretically still allow you to slide down slopes that are larger than the slope limit, but I haven't tested it yet.
     
    Last edited: Jan 31, 2014
  41. Jeremy Fuller

    Jeremy Fuller

    Joined:
    Feb 20, 2013
    Posts:
    9
    Thanks for posting this idea. I adapted it successfully to my project. I'd like to share the changes in this thread in case Greg or others want to do the same. Again, more testing still needed, but this appears to completely eliminate all sliding on moving platforms, especially platforms that move horizontally. It does not require any additional colliders or ray casts.

    1. First, we want to eliminate the original Moving Platform Friction concept, as it interferes with this new technique. On your Player object, Player Move component, set Moving Platform Friction to 0.


    2. We need to keep track of which platform we're grounded on, if any. In PlayerMove.cs, add this field to the class:
    Code (csharp):
    1.  [HideInInspector]
    2.  public GameObject currentPlatform;
    At the very top of IsGrounded(), add:
    Code (csharp):
    1. currentPlatform = null;
    Towards the bottom of IsGrounded(), change the "moving platforms" section to read:
    Code (csharp):
    1.  
    2. //moving platforms
    3. if (hit.transform.tag == "MovingPlatform" || hit.transform.tag == "Pushable")
    4. {
    5.     if (hit.transform.tag == "MovingPlatform") currentPlatform = hit.transform.gameObject; // <-- this is the only new line of code
    6.     movingObjSpeed = hit.transform.rigidbody.velocity;
    7.     movingObjSpeed.y = 0f;
    8.     //9.5f is a magic number, if youre not moving properly on platforms, experiment with this number
    9.     rigidbody.AddForce(movingObjSpeed * movingPlatformFriction * Time.fixedDeltaTime, ForceMode.VelocityChange);
    10. }
    3. Now we need to keep track of the platform's movement and translate the player if needed. I put this in as an option in case you don't want the player stuck to the platform like this (it's not needed for vertically-moving platforms).

    In MoveToPoints.cs, add this code at the top of the class:
    Code (csharp):
    1.  public bool translatePlayer; // Set to true to translate the player in sync with the platform. This keeps the player on the platform.
    2.  private Vector3 positionLastFrame;
    3.  private GameObject player;
    4.  private PlayerMove playerMove;
    At the end of Awake(), add the following code to cache our player object and the PlayerMove script:
    Code (csharp):
    1.  
    2. player = GameObject.FindGameObjectWithTag("Player");
    3. playerMove = player.GetComponent<PlayerMove>();
    And finally, here is my entire FixedUpdate() function. The new code is at the top:
    Code (csharp):
    1.  
    2. void FixedUpdate()
    3. {
    4.     if (translatePlayer  playerMove.currentPlatform == this.gameObject)
    5.     {
    6.         Vector3 delta = transform.position - positionLastFrame;
    7.         player.transform.position += delta;
    8.     }
    9.     positionLastFrame = transform.position;
    10.     if (transform.tag != "Enemy")
    11.     {
    12.         if(!arrived  waypoints.Count > 0)
    13.         {
    14.             Vector3 direction = waypoints[currentWp].position - transform.position;
    15.             rigidbody.MovePosition(transform.position + (direction.normalized * speed * Time.fixedDeltaTime));
    16.         }
    17.     }
    18. }
    19.  
    4. In order for this to work right, you need to alter your script execution order to make sure PlayerMove.cs runs first. See this link for instructions: http://docs.unity3d.com/Documentation/Components/class-ScriptExecution.html


    Hope this helps! I'll continue testing to see if these changes caused any unforeseen issues. Greg, sorry for posting this much code, hopefully you don't mind.
     
    Last edited: Jan 31, 2014
  42. hensoup

    hensoup

    Joined:
    Jan 13, 2014
    Posts:
    35
    NOPE I did a better solution I think as I preferred my results.

    First Put this as the initialization variables

    Code (csharp):
    1.  
    2.     public bool moveplat;
    3.     public Vector3 offset;
    4.     //setup
    5.  
    Then on Fixed Update add this! below grounded = IsGrounded ();

    Code (csharp):
    1.  
    2.  
    3.         if(!grounded)
    4.             moveplat = false;
    5.  
    finally change the mov

    Code (csharp):
    1.  
    2. if (hit.transform.tag == "MovingPlatform" || hit.transform.tag == "Pushable")
    3.                     {
    4.                         if(moveplat == false){
    5.                             offset =  new Vector3((transform.position.x - hit.transform.position.x),0,(transform.position.z - hit.transform.position.z));
    6.                             moveplat = true;
    7.                         }
    8.  
    9.                         if(direction.magnitude == 0){
    10.                             transform.position = new Vector3(hit.transform.position.x + offset.x,transform.position.y,hit.transform.position.z+ offset.z);
    11.                         }else{
    12.                             characterMotor.MoveTo (direction + (hit.transform.position + offset),100, 4.7f, true);
    13.                             moveplat = false;
    14.                         }
    15. }
    16.  
    I just added a moveplat boolen and a offest vector and this worked

    Eidit Wait I did some extra to this as well.
     
    Last edited: Jan 31, 2014
  43. Jeremy Fuller

    Jeremy Fuller

    Joined:
    Feb 20, 2013
    Posts:
    9
  44. devandart

    devandart

    Joined:
    Jun 7, 2013
    Posts:
    144
    Hi,

    I just bought your package and it's really awesome and so intuitive to use!
    Keep up the good work.
    For beginners you should describe more detailed how to set up the collider size for other characters to not get physics problems. :)

    To use a Xbox 360 controller you only have to create some additional Inputs like "Grab", "Jump"... (same name like the existing ones) and then map them to the Xbox controller described on this site http://wiki.unity3d.com/index.php?title=Xbox360Controller

    If sb. needs help, contact me via pm.
     
  45. rickcollette

    rickcollette

    Joined:
    Mar 17, 2013
    Posts:
    304
    Ok - I am having a complete brain block here. How the heck are you guys getting the player character matched up with the controller? I tinkered with it for a few hours on saturday and came up close.. but not quite.
     
  46. MaartenUT

    MaartenUT

    Joined:
    Aug 21, 2013
    Posts:
    18
    Hey Greg, loving your kit!

    I'm almost ready to upload my game to the play store :D It's called Dobbler, and your kit is what made it reality :)
    Thanks again!

    PS: Here's the site for Dobbler: dobbler.weebly.com
     
  47. devandart

    devandart

    Joined:
    Jun 7, 2013
    Posts:
    144
    @arrested_games: What's your exact problem?

    I have a problem with animations. I created a model in Blender with a simple rig and a animation action called "Walk" for example.
    When I import the model into Unity it recognizes and playback the animation in the model inspector.
    Then I replaced the example player model with my model and attached the Player Controller to it and replaced the walk state animation with my animation clip. Of course I added the controller to the scripts (PlayerMove and Throwing).
    But when I walk around my character doesn't animate.
    The model import-settings (rig for e.g.) are the same as yours.

    Is there another thing I forgot to edit?

    Edit: I created a new player out of the Player prefab and ONLY replaced the model and animation clips, not the colliders. Now the animation works. Hm...

    Edit 2: I set all animations in the Player animation Controller to "None" and put in only my animations. Then it works also with edited colliders.
     
    Last edited: Feb 5, 2014
  48. rickcollette

    rickcollette

    Joined:
    Mar 17, 2013
    Posts:
    304
    Following the guide; I end up with the following: http://pachewy.com/Issues/
    It is easier to show than to try and explain, I think.

    You will see that the collision is way off center, that the controller is off, and that the model is backward (that part I can fix easy enough) - my concern is that after messing around with the collision box, its always the same - off by a bit, and the controller is weird.
     
  49. tequyla

    tequyla

    Joined:
    Jul 22, 2012
    Posts:
    335
    Hi,


    is ladder in this package?


    +++
     
  50. Jeremy Fuller

    Jeremy Fuller

    Joined:
    Feb 20, 2013
    Posts:
    9
    Nope.