Search Unity

New Standard Assets - a.k.a. Sample Assets, Beta Release

Discussion in 'Assets and Asset Store' started by duck, Jan 17, 2014.

  1. markharkness

    markharkness

    Unity Technologies

    Joined:
    Nov 2, 2010
    Posts:
    176
    most of these are going to be handled in another project that we will be doing. The likelyhood of that is that these addition will be ported back into the sample assets.
     
  2. Reanimate_L

    Reanimate_L

    Joined:
    Oct 10, 2009
    Posts:
    2,788
    Ooh that would be awesome :)
     
  3. sti_22

    sti_22

    Joined:
    Oct 1, 2014
    Posts:
    4
    Attached my version.
    I also changed guiBoundary from rect to circle (using ClampPositionToCircle from this forum).
     

    Attached Files:

    • src.zip
      File size:
      3.9 KB
      Views:
      589
  4. Reanimate_L

    Reanimate_L

    Joined:
    Oct 10, 2009
    Posts:
    2,788
    Oohh @tnetennba any idea or plan to make TPS working with ragdoll or vice versa?? since it using rigidbody controller for some reason it's not working together with ragdoll
     
  5. markharkness

    markharkness

    Unity Technologies

    Joined:
    Nov 2, 2010
    Posts:
    176
    Unlikely. Ragdoll is an edge case usage that we don't want to cover. We are trying to provide solid basic example of usage and creating the ragdoll effect would make the example more complex than we would like.
     
  6. Reanimate_L

    Reanimate_L

    Joined:
    Oct 10, 2009
    Posts:
    2,788
    Ah, good point. okay noted :D
     
  7. markharkness

    markharkness

    Unity Technologies

    Joined:
    Nov 2, 2010
    Posts:
    176
    If everyone using Unity was master then there are so many sweet features and things that we could add to this but as it stands it needs to basic enough for new users to get to grips with but allow experienced users to be able to expand upon if they like.
     
  8. Max1982

    Max1982

    Joined:
    Oct 16, 2014
    Posts:
    133
    Hi guys, anyone could tell me what's going on. I try to use Asset beta sample Car with mobile controller (via Unity Remote 4) on Windows 7. But when I hit "play" button nothing change. Gas and brake pedals on mobile iphone 4 don't work:( Static screen and nothing else. Touch buttons dont work. Please help, what's wrong
     
    Last edited: Oct 20, 2014
  9. Max1982

    Max1982

    Joined:
    Oct 16, 2014
    Posts:
    133
    Ok, so I've checked demo scene from Unity Beta Asset Sample and only airplane works on iPhone 4 (car, and 2d platform are not working). This time I opened project in Unity 4.6 beta and now Unity Remote 4 doesnt show a screen game. Still is information: "Connect this device with a USB Cable to your computer. Press Play int the Uinty Editor Test." I select device : edit - project settings-editor to iOS devices several times, but its nothing change. Of course I also use iOS platform in Build Setting and Enable Mobile Input. Please help!

    Update: There are also bug in Car in sample Asset Beta for Unity 4.6, when I hit only forward button (accelerate), car is driving to the left side. This bug is so big when I try to build iOS project, than car is driving in the circle, when I push only "gas button" via mouse controller (because Unity Remote 4 doesnt work)
     
    Last edited: Oct 20, 2014
  10. markharkness

    markharkness

    Unity Technologies

    Joined:
    Nov 2, 2010
    Posts:
    176
    Seems to a bug with the remote on iOS not responding to touch events on the new gui system. This is not specifically related to the sample assets. I would suggest filling a bug using the help->report a bug menu from the editor.
     
  11. puzzlekings

    puzzlekings

    Joined:
    Sep 6, 2012
    Posts:
    404
    Hi

    I am in the middle of trying to upgrade a project using the old mobile car tilt control with Buttons Rig to the new one, and I am not sure of the best way to do this?

    Any ideas?

    Also I just noticed while comparing the old and previous directories that there are a few scripts missing:

    TouchPadPositional.cs
    TouchPadRelativePositional.cs
    TouchPadSwipe.cs

    Has the functionality here been included in the current version of the Touchpad.cs?

    thanks

    Nalin
     
  12. Reanimate_L

    Reanimate_L

    Joined:
    Oct 10, 2009
    Posts:
    2,788
    Speaking of, this is somehow make me curious. Which one is better for mecanim, using capsule collider with rbd or using character controller??
     
  13. Reanimate_L

    Reanimate_L

    Joined:
    Oct 10, 2009
    Posts:
    2,788
    @tnetennba Sample asset is compatible with 5 beta right??
     
  14. Zyxil

    Zyxil

    Joined:
    Nov 23, 2009
    Posts:
    111
    After installing this package two very bad things happen:
    • The included scenes are added to the current project's scenes in build and existing ones are removed or messed up.
    • The current project's Player settings are monkeyed with. Specifically, Company Name and Product Name are changed.
    Other project settings are probably changed. I understand that these things are needed to have working samples, but some warning should be given.

    IMO, sample assets should install into any existing project without messing up the current settings.
     
    BryanO likes this.
  15. markharkness

    markharkness

    Unity Technologies

    Joined:
    Nov 2, 2010
    Posts:
    176
    Some parts will and some wont. I am going to try and get a zip of the project up somewhere later on today so that people can start looking at them. The should be included in the editor installer fairly soon but I will let this thread know as soon as they are.
     
  16. Reanimate_L

    Reanimate_L

    Joined:
    Oct 10, 2009
    Posts:
    2,788
    That would be awesome, thanks btw :)
     
  17. Tiny-Tree

    Tiny-Tree

    Joined:
    Dec 26, 2012
    Posts:
    1,315
    the scene thirdPersonCharacter from 4.6 assets when i switch build to ios, i test on my ipad, only see the jump button, cant see any movement joystick sprite, is there missing reference or its normal ?
     
  18. markharkness

    markharkness

    Unity Technologies

    Joined:
    Nov 2, 2010
    Posts:
    176
  19. markharkness

    markharkness

    Unity Technologies

    Joined:
    Nov 2, 2010
    Posts:
    176
    Oh yeah just as heads up we know about planes wheels behaving strangely and I am just waiting on a fix for the problem from our physics guys.
     
  20. elbows

    elbows

    Joined:
    Nov 28, 2009
    Posts:
    2,502
    A slightly silly question about the Unity 5 version - are any of the image effects included in that presently different to the ones in the existing 'built-in' standard assets in Unity 5 beta 9?
     
  21. markharkness

    markharkness

    Unity Technologies

    Joined:
    Nov 2, 2010
    Posts:
    176
    The only differences are that they are all in c# in the sample assets and that some have been renamed.
    There might be some issues with them but I have yet to find any.
     
    elbows likes this.
  22. elbows

    elbows

    Joined:
    Nov 28, 2009
    Posts:
    2,502
    Thanks for the info :)
     
  23. puzzlekings

    puzzlekings

    Joined:
    Sep 6, 2012
    Posts:
    404
    Ok, in case this helps anyone else, I managed to upgrade just the crossplatforminput stuff from the new asset package into an existing 4.6 project using the old assets - I needed to do this to take advantage of the Car pedals being scalable with the new GUI.

    1 - I deleted the existing CPI directory and removed any scene elements for the old mobile control rig
    2 - Import just the CPI elements from the new sample asset package
    3 - Scripting errors were due to the new sample assets living in name spaces - needed an explicit import "using UnitySampleAssets.CrossPlatformInput
    4 - Update existing calls to CrossPlatformInput.xxx to CrossPlatformInputManager.xxx
    5 - Insert the new CarTiltControlWithButtons prefab into the existing scene.

    and it worked.

    HTH

    Nalin
     
  24. Vagabond_

    Vagabond_

    Joined:
    Aug 26, 2014
    Posts:
    1,148
    The First Person Controller needs Slope Limit(there is some but i can ignore it with jumping) and Platforming functionality. Without these is not useful in many genres. And also there is a small bug or miss in the logic - when you get in a 90 degree corner and you jump the controller jumps too high... The Air control doesn't work always...
    All refers to the package for 4.6
     
    Last edited: Nov 2, 2014
  25. twobob

    twobob

    Joined:
    Jun 28, 2014
    Posts:
    2,058
  26. markharkness

    markharkness

    Unity Technologies

    Joined:
    Nov 2, 2010
    Posts:
    176
    Correct
     
    twobob likes this.
  27. twobob

    twobob

    Joined:
    Jun 28, 2014
    Posts:
    2,058
    Awesome. just checked it out. Awesome.

    Much obliged there.

    As a side bonus it got me to fix my adb installation (never did get round to it before) so happy days on the remote android testing now :)

    Joybeans.
     
  28. Wahooney

    Wahooney

    Joined:
    Mar 8, 2010
    Posts:
    281
    Hey!

    I'm busy downloading the Unity 5 version now (slow assed internet here in South Africa means I'll have it in an hour ;) )

    In the mean time, I found a bug in FirstPersonController.cs, line 127 should probably read:

    Code (CSharp):
    1. _moveDir += Physics.gravity*_gravityMultiplier*Time.fixedDeltaTime;
    currently it's:

    Code (CSharp):
    1. _moveDir += Physics.gravity*_gravityMultiplier;
    That's why _gravityMultiplier and jumpSpeed need to be such high and low values respectively.

    I don't know if you've seen this before, but there it is!

    PS You should also probably keep your variable naming convention more consistent ;)
     
    twobob likes this.
  29. markharkness

    markharkness

    Unity Technologies

    Joined:
    Nov 2, 2010
    Posts:
    176

    Good spot.

    As for the naming conventions I am well aware but I am waiting until no one is going to be touching the code to avoid horrible merges etc etc.
     
  30. AndreiTache

    AndreiTache

    Joined:
    Nov 8, 2014
    Posts:
    31
    Hey, I downloaded the assets,but I cannot import them,the Import button flickers and I can't click on it...
    I have windows 7 and Unity 4.6f. I even restarted my computer and it isn't working...
     
  31. markharkness

    markharkness

    Unity Technologies

    Joined:
    Nov 2, 2010
    Posts:
    176
    Is that downloading the package from the asset store?
     
  32. twobob

    twobob

    Joined:
    Jun 28, 2014
    Posts:
    2,058
    hmm. wrong version of the package maybe? manually using 5.0 on 4.6 perhaps?
     
  33. Tethys

    Tethys

    Joined:
    Jul 2, 2012
    Posts:
    672
    Hey guys, I have a question about the Mecanim ThirdPersonCharacter prefab example provided. I want to have characters run backwards when the player presses back, unlike the demo asset where the character simply turns around and runs towards the camera. I have added two new motion fields to the walking blend tree provided and set the walk back and run back to fire off at 0, -0.5 and run back at 0, -1 (turn and Forward parameters). However, I think something in the scripts is preventing the Forward parameter from being a negative number. Anyone have any luck with that or have experience with this package and know how to change that part? I notice if I watch the Forward parameter, when I push back on the controller it goes negative briefly, then some kind of character turning kicks in and then the integer goes positive. :/ Any advice is much appreciated, thanks!
     
    Last edited: Nov 11, 2014
  34. boombaby

    boombaby

    Joined:
    Mar 20, 2013
    Posts:
    3
    Hi guys,

    what an awesome package! But maybe I'm not the first one to say that :)

    I have a question though; there seems to be something wrong with the third person controller script, and although I tried very hard to pinpoint it in the code and looked all over the forums, I still don't see where it comes from....
    When you walk (or run) around and then stop, sometimes the character will turn abruptly 90 degrees to the right. It happens especially when you were going left and then "down" (in direction of the camera). For example; in the demo scene, go up the ramp and turn left, then halt. Then walk towards the camera (S-Button) and then stop. Zang! Character will not stand there looking in camera direction as he should but magically twists to the right (...I mean to the right on its own axis, so in the game view he twists to the left, just to be clear).
    Does anyone have any idea what causes this? Would be great if someone noticed this too and could point me to the line of code that needs to be changed!

    Thank you in advance!
     
    Last edited: Nov 12, 2014
  35. RUBILYN

    RUBILYN

    Joined:
    Jun 22, 2013
    Posts:
    54
  36. AndreiTache

    AndreiTache

    Joined:
    Nov 8, 2014
    Posts:
    31
    Yes and I am using version 4.6 and tried to download the 4.6 version and the other one too...
    P.S. thank you for replying to my post =D
     
  37. eagletree

    eagletree

    Joined:
    Sep 1, 2012
    Posts:
    11
    Any progress on getting the beta sample assets link working again. I'm attempting to load them for 5.0 Beta 13.

    We have tried and really like the new assets on 4.x.
     
  38. markharkness

    markharkness

    Unity Technologies

    Joined:
    Nov 2, 2010
    Posts:
    176
    I'll get something up in the next couple of hours. We made some significant changes and I want to make sure nothing is totally broken.
     
  39. eagletree

    eagletree

    Joined:
    Sep 1, 2012
    Posts:
    11
    Thank you very much. I will watch the thread for further development.
     
  40. elbows

    elbows

    Joined:
    Nov 28, 2009
    Posts:
    2,502
    Sorry to nag but what is happening with the 5 beta version?
     
  41. markharkness

    markharkness

    Unity Technologies

    Joined:
    Nov 2, 2010
    Posts:
    176
    It will be in the next 5 beta. Currently I am crushing small annoying bugs, nothing that will break anything so my hands are tied for time and don't have the time to prep a drop for you guys sorry.
     
  42. elbows

    elbows

    Joined:
    Nov 28, 2009
    Posts:
    2,502
    Thats cool, thanks for the info :)
     
  43. rufio

    rufio

    Joined:
    Nov 21, 2012
    Posts:
    4
    I have modified the first person controller a bit to add some functionality and fix some annoying behavior, please feel free to test out and come up with improvements. Things I have added is slope limits the player can climb and sliding down from the steep slopes, correcting momentum in the air if the player hit anything (so the player does not slide over objects and seems to be shot out of a cannon), walking in stairs is working OK, user can toggle on/off movement control while in the air and moving platforms (using rigidbodies) works OK as well.

    There is one bug though, if you jump while being in a corner the player will jump higher and float a bit. Will be working on getting rid of that, but feel free to come up with some nice solution to that. Also a more elegant fix restricting movement in slopes must be written (only hinder movement upwards slope, not down). It is super messy since I have just hacked away and tried different solutions but I am sure you can clean it up yourselves.

    Code (CSharp):
    1. using UnityEngine;
    2. using System.Collections;
    3.  
    4. public class FirstPersonCharacter : MonoBehaviour
    5. {
    6.     [SerializeField] private float runSpeed = 8f;                                       // The speed at which we want the character to move
    7.     [SerializeField] private float strafeSpeed = 4f;                                    // The speed at which we want the character to be able to strafe
    8.     [SerializeField] private float jumpPower = 5f;
    9.     [SerializeField] private bool walkByDefault = true;                                    // controls how the walk/run modifier key behaves.
    10.     [SerializeField] private float walkSpeed = 3f;
    11.     [SerializeField] private AdvancedSettings advanced = new AdvancedSettings();        // The container for the advanced settings ( done this way so that the advanced setting are exposed under a foldout
    12.     [SerializeField] private bool lockCursor = true;
    13.  
    14.     [System.Serializable]
    15.     public class AdvancedSettings                                                       // The advanced settings
    16.     {
    17.         public float gravityMultiplier = 1f;                                            // Changes the way gravity effect the player ( realistic gravity can look bad for jumping in game )
    18.         public PhysicMaterial zeroFrictionMaterial;                                     // Material used for zero friction simulation
    19.         public PhysicMaterial highFrictionMaterial;                                     // Material used for high friction ( can stop character sliding down slopes )
    20.         public float groundStickyEffect = 5f;                                            // power of 'stick to ground' effect - prevents bumping down slopes.
    21.     }
    22.  
    23.     private CapsuleCollider capsule;                                                    // The capsule collider for the first person character
    24.     private const float jumpRayLength = 0.7f;                                           // The length of the ray used for testing against the ground when jumping
    25.     public bool grounded { get; private set; }
    26.     private Vector2 input;
    27.     private IComparer rayHitComparer;
    28.  
    29.     bool jumping = false;
    30.     bool canJump = true;
    31.     Vector3 desiredMove;
    32.     Vector3 oldPosition;
    33.  
    34.     [Range(25.0f, 70.0f)]
    35.     public float maxSteepness = 45.0f;
    36.  
    37.     [Range(0.1f, 0.5f)]
    38.     public float stepOffset = 0.4f;
    39.  
    40.     public bool walkInStairs = true;
    41.     bool takingStep = false;
    42.  
    43.     [Range(0.05f, 0.5f)]
    44.     public float stairStepTime = 0.2f;
    45.  
    46.     public bool enableMovingPlatforms = true;
    47.     public bool canControlInAir = false;
    48.     public bool correctAirMomentum = true;
    49.  
    50.     void Awake ()
    51.     {
    52.         // Set up a reference to the capsule collider.
    53.         capsule = collider as CapsuleCollider;
    54.         grounded = true;
    55.         Screen.lockCursor = lockCursor;
    56.         rayHitComparer = new RayHitComparer();
    57.     }
    58.  
    59.     void OnDisable()
    60.     {
    61.         Screen.lockCursor = false;
    62.     }
    63.  
    64.     bool jump = false;
    65.  
    66.     void Update()
    67.     {
    68.         if (Input.GetMouseButtonUp(0))
    69.         {
    70.             Screen.lockCursor = lockCursor;
    71.         }
    72.  
    73.         if(grounded && canJump && Input.GetButtonDown("Jump"))
    74.         {
    75.             jump = true;
    76.         }
    77.     }
    78.  
    79.  
    80.     public void FixedUpdate ()
    81.     {
    82.         if (!takingStep)
    83.         {
    84.             float speed = runSpeed;
    85.  
    86.             float h = Input.GetAxis("Horizontal");
    87.             float v = Input.GetAxis("Vertical");
    88.  
    89.             // On standalone builds, walk/run speed is modified by a key press.
    90.             // We select appropriate speed based on whether we're walking by default, and whether the walk/run toggle button is pressed:
    91.             bool walkOrRun = Input.GetKey(KeyCode.LeftShift);
    92.             speed = walkByDefault ? (walkOrRun ? runSpeed : walkSpeed) : (walkOrRun ? walkSpeed : runSpeed);
    93.  
    94.             //we can only control the player when he is grounded
    95.             if (canControlInAir)
    96.             {
    97.                 input = new Vector2(h, v);
    98.                 // normalize input if it exceeds 1 in combined length:
    99.                 if (input.sqrMagnitude > 1) input.Normalize();
    100.                 // Get a vector which is desired move as a world-relative direction, including speeds
    101.                 desiredMove = transform.forward * input.y * speed + transform.right * input.x * strafeSpeed;
    102.             }
    103.             else if(grounded)
    104.             {
    105.                 input = new Vector2(h, v);
    106.                 // normalize input if it exceeds 1 in combined length:
    107.                 if (input.sqrMagnitude > 1) input.Normalize();
    108.                 // Get a vector which is desired move as a world-relative direction, including speeds
    109.                 desiredMove = transform.forward * input.y * speed + transform.right * input.x * strafeSpeed;
    110.             }
    111.  
    112.             // preserving current y velocity (for falling, gravity)
    113.             float yv = rigidbody.velocity.y;            
    114.  
    115.             // add jump power
    116.             if (grounded && jump && canJump)
    117.             {
    118.                 yv += jumpPower; //yv = jumpPower; //Platform jumps seems sorted so no need to disable additative jumping
    119.                 grounded = false;
    120.                 jump = false;
    121.                 jumping = true;
    122.             }
    123.  
    124.             //player can never gain momentum after it is lost in the air (after something being hit
    125.             if (correctAirMomentum && !grounded)
    126.             {
    127.                 correctMomentum();          
    128.             }
    129.  
    130.             // Set the rigidbody's velocity according to the ground angle and desired move
    131.             rigidbody.velocity = desiredMove + Vector3.up * yv;
    132.  
    133.             // Use low/high friction depending on whether we're moving or not
    134.             if (desiredMove.magnitude > 0 || !grounded)
    135.             {
    136.                 collider.material = advanced.zeroFrictionMaterial;
    137.             }
    138.             else
    139.             {
    140.                 collider.material = advanced.highFrictionMaterial;
    141.             }
    142.  
    143.             // Ground Check:
    144.             if (grounded || rigidbody.velocity.y < jumpPower * .5f)
    145.             {
    146.                 checkIsGrounded();
    147.             }      
    148.  
    149.             //walking up stairs
    150.             if (walkInStairs && grounded && (transform.position - oldPosition).sqrMagnitude < 0.1f) //input.y > 0.0f &&
    151.             {
    152.                 checkStairStep();
    153.             }
    154.  
    155.             //Debug.DrawRay(ray.origin, ray.direction * capsule.height * jumpRayLength, grounded ? Color.green : Color.red );
    156.  
    157.  
    158.             // add extra gravity
    159.             if (advanced.gravityMultiplier > 1)
    160.             {
    161.                 rigidbody.AddForce(Physics.gravity * (advanced.gravityMultiplier - 1));
    162.             }
    163.         }
    164.  
    165.         //save old position to use when calculating "real speed" and loss of momentum
    166.         oldPosition = transform.position;
    167.     }
    168.  
    169.     private void correctMomentum()
    170.     {
    171.         float xSpeed = Mathf.Abs(transform.position.x - oldPosition.x) / Time.fixedDeltaTime;
    172.         xSpeed = Mathf.Min(Mathf.Abs(desiredMove.x), xSpeed);
    173.         xSpeed = xSpeed * Mathf.Sign(desiredMove.x);
    174.         float zSpeed = Mathf.Abs(transform.position.z - oldPosition.z) / Time.fixedDeltaTime;
    175.         zSpeed = Mathf.Min(Mathf.Abs(desiredMove.z), zSpeed);
    176.         zSpeed = zSpeed * Mathf.Sign(desiredMove.z);
    177.    
    178.         desiredMove = new Vector3(xSpeed, 0, zSpeed);
    179.     }
    180.  
    181.     private void checkIsGrounded()
    182.     {  
    183.         // Create a ray that points down from the centre of the character.
    184.         Ray ray = new Ray(transform.position, -transform.up);
    185.  
    186.         // Raycast slightly further than the capsule (as determined by jumpRayLength)
    187.         //RaycastHit[] hits = Physics.RaycastAll(ray, capsule.height * jumpRayLength);
    188.         RaycastHit[] hits = Physics.RaycastAll(ray, capsule.height / 2.0f + 0.4f);
    189.         System.Array.Sort(hits, rayHitComparer);
    190.  
    191.         // Default value if nothing is detected:
    192.         grounded = false;
    193.         // Check every collider hit by the ray
    194.         for (int i = 0; i < hits.Length; i++)
    195.         {
    196.             // Check it's not a trigger
    197.             if (!hits[i].collider.isTrigger)
    198.             {
    199.                 // The character is grounded, and we store the ground angle (calculated from the normal)
    200.                 grounded = true;
    201.                 //we no longer jump since we have touched ground
    202.                 jumping = false;
    203.  
    204.                 // stick to surface - helps character stick to ground - specially when running down slopes
    205.                 //if (rigidbody.velocity.y <= 0) {
    206.                 rigidbody.position = Vector3.MoveTowards(rigidbody.position, hits[i].point + Vector3.up * capsule.height * 0.5f, Time.deltaTime * advanced.groundStickyEffect);
    207.                 //}
    208.                 rigidbody.velocity = new Vector3(rigidbody.velocity.x, 0, rigidbody.velocity.z);
    209.  
    210.                 //check steepness of surface, hamper movement (also press playr down) and jump ability if applicable
    211.                 if (Vector3.Angle(hits[i].normal, Vector3.up) > maxSteepness)
    212.                 {
    213.                     collider.material = advanced.zeroFrictionMaterial;
    214.                     rigidbody.velocity = new Vector3(rigidbody.velocity.x * 0.3f, -5.0f, rigidbody.velocity.z * 0.3f);
    215.                     canJump = false;
    216.                 }
    217.                 else
    218.                 {
    219.                     canJump = true;
    220.                 }
    221.  
    222.                 //if we support moving platforms, check if it is a rigidbody and if so call function to add velocity
    223.                 if (enableMovingPlatforms && hits[i].rigidbody)
    224.                 {
    225.                     checkMovingPlatform(hits[i].rigidbody);
    226.                 }
    227.  
    228.                 break;
    229.             }
    230.         }
    231.     }
    232.  
    233.     private void checkMovingPlatform(Rigidbody movingObject)
    234.     {
    235.         rigidbody.velocity += movingObject.velocity;
    236.     }
    237.  
    238.     private void checkStairStep()
    239.     {
    240.         // Create a ray that points down in front of the player
    241.         Vector3 forwardVector = rigidbody.velocity.normalized;
    242.         Ray stepRay = new Ray(transform.position + forwardVector * capsule.radius, -transform.up);
    243.         //Ray stepRay = new Ray(transform.position + transform.forward * capsule.radius, -transform.up);
    244.  
    245.         // Raycast slightly further less than the capsule (smaller objects are no problem to walk over anyway)
    246.         RaycastHit[] hits = Physics.RaycastAll(stepRay, capsule.height / 2.0f - 0.05f);
    247.         System.Array.Sort(hits, rayHitComparer);
    248.  
    249.         if (grounded)
    250.         {
    251.             // Check every collider hit by the ray
    252.             for (int i = 0; i < hits.Length; i++)
    253.             {
    254.                 // Check it's not a trigger
    255.                 if (!hits[i].collider.isTrigger)
    256.                 {
    257.                     //since we only wish to use this on steps and not inclined platforms we check the normal direction (should point straigth upward)
    258.                     if (Vector3.Angle(hits[i].normal, Vector3.up) < 1.0f)
    259.                     {
    260.                         //check that the hit point is actually low enough to walk up on
    261.                         if (hits[i].point.y < transform.position.y - capsule.height / 2.0f + stepOffset)
    262.                         {      
    263.                             //if nothing in front of player we take the step up and forward        
    264.                             if (freeForward(forwardVector))
    265.                             {
    266.                                 float stepSize = hits[i].point.y - (transform.position.y - capsule.height / 2.0f);
    267.                                 StartCoroutine(takeStep(forwardVector, stepSize));
    268.                             }                      
    269.                             break;
    270.                         }
    271.                     }
    272.                 }
    273.             }
    274.         }
    275.     }
    276.  
    277.     private bool freeForward(Vector3 forwardVector)
    278.     {
    279.         // Create a ray that points in front of the player movement direction
    280.         bool forwardIsFree = true;
    281.         Ray forwardRay = new Ray(transform.position, forwardVector);
    282.         //Ray forwardRay = new Ray(transform.position, transform.forward);
    283.  
    284.         // Raycast 2 radiuses in fron of the player since we will move that long if taking step
    285.         RaycastHit[] hits = Physics.RaycastAll(forwardRay, 2.0f * capsule.radius);
    286.         System.Array.Sort(hits, rayHitComparer);
    287.  
    288.         // Check every collider hit by the ray
    289.         for (int i = 0; i < hits.Length; i++)
    290.         {
    291.             // Check it's not a trigger
    292.             if (!hits[i].collider.isTrigger)
    293.             {
    294.                 forwardIsFree = false;
    295.                 break;
    296.             }
    297.         }
    298.  
    299.         return forwardIsFree;
    300.     }
    301.  
    302.     private IEnumerator takeStep(Vector3 forwardVector, float stepSize)
    303.     {
    304.         takingStep = true;
    305.         rigidbody.isKinematic = true;
    306.         float t = 0.0f;
    307.  
    308.         Vector3 startPos = transform.position;
    309.         Vector3 endPos = transform.position + forwardVector * capsule.radius + transform.up * stepSize;
    310.         //Vector3 endPos = transform.position + transform.forward * capsule.radius + transform.up * stepSize;
    311.  
    312.         while (t < stairStepTime)
    313.         {
    314.             transform.position = Vector3.Lerp(startPos, endPos, t / stairStepTime);
    315.             t += Time.deltaTime;
    316.             yield return null;
    317.         }
    318.         transform.position = endPos;
    319.  
    320.         /*Vector3 startPos = transform.position;
    321.         Vector3 endPos = transform.position + transform.forward * capsule.radius;
    322.    
    323.  
    324.         while (t < 0.1f)
    325.         {
    326.             transform.position = Vector3.Lerp(startPos, endPos, t / 0.10f);
    327.             t += Time.deltaTime;
    328.             yield return null;
    329.         }
    330.         transform.position = endPos;
    331.  
    332.         startPos = transform.position;
    333.         endPos = transform.position + transform.up * stepSize;
    334.         t = 0.0f;
    335.  
    336.         while (t < 0.1f)
    337.         {
    338.             transform.position = Vector3.Lerp(startPos, endPos, t / 0.10f);
    339.             t += Time.deltaTime;
    340.             yield return null;
    341.         }
    342.         transform.position = endPos;*/  
    343.  
    344.         rigidbody.isKinematic = false;
    345.         takingStep = false;
    346.     }
    347.  
    348.  
    349.     //used for comparing distances
    350.     class RayHitComparer: IComparer
    351.     {
    352.         public int Compare(object x, object y)
    353.         {
    354.             return ((RaycastHit)x).distance.CompareTo(((RaycastHit)y).distance);
    355.         }
    356.     }
    357. }
    358.  
    EDIT:
    Fixed the sticking to corners/jumping too high in corners problem, has something to do with the gravity. So disable the rigidbody gravity and use this instead:

    Code (CSharp):
    1.  
    2. public bool useCustomGravity = true;
    3. public Vector3 customGravity = new Vector3(0, -9.81f, 0);
    4.  
    5. void Awake()
    6. {
    7.         if (useCustomGravity)
    8.         {
    9.             this.rigidbody.useGravity = false;
    10.         }
    11.         else
    12.         {
    13.             this.rigidbody.useGravity = true;
    14.         }
    15. }
    16.  
    17. //Last in FixedUpdate
    18. if (useCustomGravity && !grounded)
    19. {
    20.     rigidbody.velocity += customGravity * Time.fixedDeltaTime;
    21. }
    22.  
    EDIT2:
    Think I solved the restriction of player movement on too steep surfaces, replace
    Code (Csharp):
    1.  
    2. rigidbody.velocity = new Vector3(rigidbody.velocity.x * 0.3f, -5.0f, rigidbody.velocity.z * 0.3f);
    3.  
    with

    Code (Csharp):
    1.  
    2. if(Vector3.Angle(rigidbody.velocity, hits[i].normal) > 90.0f)
    3.                     {
    4.                         rigidbody.velocity = new Vector3(0, 0, 0);
    5.                     }  
    6.  
    That way the player can run freely downwards but not upwards.
     
    Last edited: Nov 21, 2014
  44. waterpistol78

    waterpistol78

    Joined:
    Nov 9, 2014
    Posts:
    1
    In the sample assets i want to make the car turn faster and at a better 90 degree like angle depending like what i have done in the script to make it faster by bumping up the max speed, is there a certain line of code to make the car turn faster or would i have to create one (i am horrid at scripting so making my own isn't really an option :/ ) i would really appreciate it, and thanks.
     
  45. BryanO

    BryanO

    Joined:
    Jan 8, 2014
    Posts:
    186
    In attempting to use the waypoint scripts in the beta assets bundle I've created a path of empty game objects and placed them all in a empty parent object and assigned the waypointcircuit.cs to the parent however when I press the button "assign using all child objects" to generate the waypoints nothing happens. Is there any documentation for these scripts? Does the waypoint progress tracker actually move an object through the circuit ? Assuming one gets the first script working.
     
  46. eagletree

    eagletree

    Joined:
    Sep 1, 2012
    Posts:
    11
    Is there any estimate on when the version of the beta will be available that has these new assets in it? Sorry to nag, but transitioning to 5 is going to be quite major, and I'm trying to get a jump on that since we have an unreleased game. The fellow I work with feels the new assets package will be critical.
     
  47. FargleBargle

    FargleBargle

    Joined:
    Oct 15, 2011
    Posts:
    774
    They've been averaging about one new beta per week lately, so it shouldn't be long. That said, you shouldn't be counting on beta software for anything with a deadline attached to it. Betas are meant for testing, and working out bugs before a final release. Features may also change, forcing you to redo a lot of your work. Learn what you can from them, but if you've already got a game in the pipeline, and time is critical, you should work with what's available now, not some unpredictable future release.
     
  48. Max1982

    Max1982

    Joined:
    Oct 16, 2014
    Posts:
    133
    Hi guys, Please anybody know how to put on right arrow and left arrow car control in unity Car Sample Beta Asset? Because in demo Asset Beta Sample are only Gas Pedal and Breake Pedal. :( I would like to have also arrows to control the car like in picture below.

    Nowy obraz mapy bitowej (6).jpg
     
  49. Silly_Rollo

    Silly_Rollo

    Joined:
    Dec 21, 2012
    Posts:
    501
    Looking through the new u5 beta assets and noticed that you declare a MovementSettings.BackwardSpeed but can't ever see how it is used. Is that an omission or am I missing something?
     
  50. markharkness

    markharkness

    Unity Technologies

    Joined:
    Nov 2, 2010
    Posts:
    176
    just so you know im not ignoring you folks im just flat out at the moment. As soon as I get some time I'll get to your questions and I will also update the 4.6 version of the sample assets now that the final release is out.
     
    vferguson likes this.