Search Unity

[RELEASED]Bicycle PRO kit (bicycle physics and stunts)

Discussion in 'Assets and Asset Store' started by bcman, Sep 27, 2016.

  1. bcman

    bcman

    Joined:
    Feb 9, 2013
    Posts:
    139
    Bicycle PRO kit

    Hello every one 'two wheels' enthusiasts.

    Before any words watch short trailer of features.



    TRY playable Web version
    (IExplorer, Firefox, Opera)

    TRY playable OpenGL version
    (Chrome, Edge)
    (sorry for graphics quality of OpenGL version - it's still WiP)


    AssetStore download link



    There is main features you'll get:

    • Two bicycles as examplses(Dirt and Full Suspension)
    • Realistic rotation of pedals(pedaling)
    • Nice and looking good Suspension
    • Two independent brakes
    • Trail braking
    • Pilot's weight transferring
    • IK head looking at
    • Pilot's IK animation and physics reaction to action
    • Sounds
    • Skidmarks
    • Reverse speed
    • Example stunts: "Manual", "Backflip360", "Side Bunnyhop", "Right180"

    As a bicycle rider too I've try to achieve the feeling of real bicycle behavior.
    All my riding experience included in this package.
    Not only mathematical knowledge, but the thrill of riding a bicycle and the behavior of bicycle in various situations.


    Features explain:
    Pedaling
    - realistic shifting center of mass to simulate powerfull pedaling with all leg's force applying to lefr or right pedal
    Suspension - you might crteate any kind of bicycle in 3D package and it will 'bends' in right way. Front and rear suspensions will squeeze properly in any angle with any frame construction.
    Two independent brakes - rear and front can be used separately for different effects
    Trail braking - technique of cornering with a slight rear wheel skid
    Rider's weight transferring - advanced technique when you might shift rider's position to load or unload front or rear wheel. It used for some stunts and wheelie/stoppie control
    IK head - feature to look at any objects you like
    Pilot's IK animation and physics reaction to action - pilot inherits some inertia from any action with bicycle.
    Reverse speed - you can push bike back when you are going wrong way
    Stunts - as it sounds like :) You may do some premade stunts for write your own by applying forces to bicycle and rider.






    I wish to improve my project more and more, so wait for suggestions.
    Ask anything :)
     
    Last edited: Jan 15, 2017
    tapawafo and Hamesh81 like this.
  2. bcman

    bcman

    Joined:
    Feb 9, 2013
    Posts:
    139
    It's released !
     
  3. kklu

    kklu

    Joined:
    Oct 19, 2016
    Posts:
    1
    Hi. Is there any constrain in the construction of bicycle. Example, the parts in a bicycle, the style , construction and the location of colliders of a bicycle? Is there tools to build a bicycle and pilot model?
     
  4. bcman

    bcman

    Joined:
    Feb 9, 2013
    Posts:
    139
    Hello, kklu.

    What you mean by "constrains" ? You may do any type of bike BMX, three wheels, no suspension, with different whees sizes. Mountbike(no rear suspension) and downhill bike(full suspension) shows the universal structure of this asset.

    All stuff you mentioned above: parts, style ,construction and the location of colliders is up to you. There is nothing impossible to implement.
    For now there is no gearing system. I've detach it because there is fun not physics.

    There is no tools for construct bicycle or rider. My tool was Maya :)
    So, any 3d package is good.
     
  5. Andreas12345

    Andreas12345

    Joined:
    Oct 17, 2013
    Posts:
    526
  6. Hamesh81

    Hamesh81

    Joined:
    Mar 9, 2012
    Posts:
    405
    Hi @bcman , this is a fantastic asset, I have been looking for this kind of stunt bicycle controller for some time now. Great work! I have tried out the demo and would like to purchase this asset but I have a few questions.

    1) Is it possible to have basic quarter pipe physics where when the rider jumps up in a quarter pipe, as they drop through the air they rotate to face back down the quarter pipe instead of falling down with their back facing the half pipe?
    eg.

    I imagine this could work by detecting the bicycle's x axis rotation and if it is close to vertical and starting to fall back to the ground, a quick sideways rotation could be applied to turn the bicycle to face down towards the ground, if that makes sense.

    2) In the demo I found myself falling off the bicycle quite bit. Is there a setting to make the falling more forgiving, for example for an easy/beginner level? For the harder difficulties I would leave it as is though.

    3) When doing the backflip and 180, I was only able to get one backflip or 180 even when doing very large jumps. Is it possible to have the bicycle continue to rotate for as long as a button is pressed to allow for a double back flip, triple back flip and 360, 540? Also, are these stunts controlled via animation or physics?

    Lastly I was wondering if you are considering doing a skateboard controller that is similar to this? This asset has all of the features that I would need but if not, I am wondering how difficult it would be for me to replace the bicycle model with a skateboard? I look forward to your reply as this is a great looking asset.
     
    Last edited: Jan 27, 2017
  7. bcman

    bcman

    Joined:
    Feb 9, 2013
    Posts:
    139
    Hello, Hamesh81.

    1. Yes, you can.
    Isn't it 1:05 on video ?


    2. To prevent falls you should press '/' just before stunt to hold bike hard :) it gives you 1 second to do any stunt(you might to configure it). Without it you will fall from bike when bike is leaned by critical angles(it also can be configured).

    3. Press backflip key again for one more 180 :)
    Also, you might to script your own stunts in code.
    It's not animations but Unity's physics.




    As for skate... making skate controlled by keyboard seems not fun for me, that's why I've made this:
    (home video 18+ :) so, you've been warned :))
    Project is freezed right now ;(
    The only thing I didn't finish it is how to accelerate/stop board ? still no idea :(
     
  8. Hamesh81

    Hamesh81

    Joined:
    Mar 9, 2012
    Posts:
    405
    Ah ok great, that sounds great. I will be purchasing this shortly :D

    Just one more question; for the rider character animations, are these compatible with mecanim's humanoid?
     
    Last edited: Jan 27, 2017
  9. bcman

    bcman

    Joined:
    Feb 9, 2013
    Posts:
    139
    Yes, mecanim skeleton is used here.
    As well as standard ragdoll for crashes.
     
  10. Hamesh81

    Hamesh81

    Joined:
    Mar 9, 2012
    Posts:
    405
    Awesome, thanks for that @bcman !
     
  11. Hamesh81

    Hamesh81

    Joined:
    Mar 9, 2012
    Posts:
    405
    Hi @bcman , just bought this asset and I'm really happy with it! Great work ;)

    I have one question though, I would like to change the input for the 180 and 360 stunts. Instead of spinning once after getkeydown I would like the bike to spin for as long as the key is held (getkey), and if the key is released the spinning stops. In other words instead of doing a 180 each time a button is pressed, if the key is held for let's say 0.5 seconds the bike does a 180, if it continues to be held the biker will keep spinning and do a 360 after another 0.5 seconds, then 540 etc etc. The longer the key is held the more rotations the bike will do and releasing the key at any point will stop the rotation. Does that make sense?
     
  12. bcman

    bcman

    Joined:
    Feb 9, 2013
    Posts:
    139
    Hello, Hamesh81.

    It's easy.
    find 'Input.GetKeyDown' strings in code.
    This means key will 'works' just once. Just when pressed. Like single shot.

    Change it to 'Input.GetKey' - key will do job every frame update.
    'Returns true while the user holds down the key identified by name. Think auto fire.' - from Unity's manual.
     
  13. Hamesh81

    Hamesh81

    Joined:
    Mar 9, 2012
    Posts:
    405
    Hi @bcman , the issue I'm having is that when using GetKey after releasing the key the bike continues to rotate instead of stopping straight away. It's almost as though it wants to keep spinning until it reaches the 180, even though the input is no longer being pressed. Do I need to do another check for GetKeyUp to stop the spin? How would this work?

    Also, I have wrote another script which is freezing the rigidbody rotation when the bike enters a trigger and unfreezes it when the bike exits.

    rigidbody.constraints=RigidbodyConstraints.FreezeRotation;
    rigidbody.constraints=RigidbodyConstraints.None;

    I am having a strange issue though where after exitting the trigger I can no longer turn anymore. Any ideas why this is happening? The rigidbody constraints do get turned off as I can see them unchecked in the inspector. I can still move forward and jump, but turning left/right doesn't work and trying to spin 180 (m key) also no longer works.
     
    Last edited: Feb 6, 2017
  14. bcman

    bcman

    Joined:
    Feb 9, 2013
    Posts:
    139
    Hello, Hamesh81.
    By pressing this key you makes an physical impulse. And it's usual way when bike continue rotation after impulse is finished. It's inertia. What happens in real life ? How riders stop inertia ? He applies the counter force to object with inertia.
    Why don't you try to apply once some kind of counter force when key is up ?

    It's just and suggestion. Don't want to say - it's one only and the best way.
     
  15. Hamesh81

    Hamesh81

    Joined:
    Mar 9, 2012
    Posts:
    405
    Hi @bcman , thanks for that. I managed to resolve the rotation keys.

    Any suggestions for the second issue, the rotation freezing? Here is my question from the previous post:

    I have wrote another script which is freezing the rigidbody rotation when the bike enters a trigger and unfreezes it when the bike exits.

    rigidbody.constraints=RigidbodyConstraints.FreezeRotation;
    rigidbody.constraints=RigidbodyConstraints.None;

    I am having a strange issue though where after exiting the trigger I can no longer turn anymore. Any ideas why this is happening? The rigidbody constraints do get turned off as I can see them unchecked in the inspector. I can still move forward and jump, but turning left/right doesn't work and trying to spin 180 (m key) also no longer works. How can I limit the rotation of an axis temporarily?
     
  16. bcman

    bcman

    Joined:
    Feb 9, 2013
    Posts:
    139
    Give me few days to create this case and try to solve.
    I've never used before such hard methods to prevent movement like 'FreezeRotation', so have no idea what happens there.
     
    Hamesh81 likes this.
  17. Hamesh81

    Hamesh81

    Joined:
    Mar 9, 2012
    Posts:
    405
    No problems @bcman , it doesn't necessarily have to be "FreezeRotation"; I simply need a way to disable rotation on a specific axis of the bicycle when entering a trigger, and then enabling it again when exiting the trigger.
    eg.
    OnTriggerEnter disable X & Z rotation
    OnTriggerExit enable X & Z rotation
    Or
    OnTriggerEnter disable X,Y & Z rotation
    OnTriggerExit enable X,Y & Z rotation
    etc

    If there is a better way to do this please let me know.
     
  18. Der_Kevin

    Der_Kevin

    Joined:
    Jan 2, 2013
    Posts:
    517
    is there any upgrade possible for the sportbike pro kit? i bought the sportbike kit cause you mentioned that you might upgrade it to also work with bicycles and now its a new pack?
    also, is it still written in javascript?
     
  19. bcman

    bcman

    Joined:
    Feb 9, 2013
    Posts:
    139
    Hello, Der_Kevin.

    I've tried to make bicycle as upgrade to SPK but there is such different physics and ideology of movement and masses of rider and bike.
    That's why I've made this asset.
    Yes, it's mostly JS.
     
  20. Der_Kevin

    Der_Kevin

    Joined:
    Jan 2, 2013
    Posts:
    517
    alright, can understand the first point.
    do you plan to change it to c# ?
    its just very annoying to switch from one language to another in a project
     
  21. TareqProjects

    TareqProjects

    Joined:
    Jun 27, 2016
    Posts:
    55
    Would it be possible to use this for NPCs? I plan on having a couple of NPC riding around an environment on a predefined loop. Would I need to have a pre-riggeed cyclist?
     
  22. bcman

    bcman

    Joined:
    Feb 9, 2013
    Posts:
    139
    Yes, it's near to be done.

    To use it on NCP you need to write simple AI, which will accelerate/decelerate, and turn steering bar to waypoints. But you should to write it yourself.
     
    Der_Kevin likes this.
  23. rohitjayakaran

    rohitjayakaran

    Joined:
    Apr 24, 2015
    Posts:
    3
    Hi

    I am looking for a way to change bike controls from key held to key press. So user has to press key again and again to power up the bike rather than holding key down.
     
  24. bcman

    bcman

    Joined:
    Feb 9, 2013
    Posts:
    139
  25. rohitjayakaran

    rohitjayakaran

    Joined:
    Apr 24, 2015
    Posts:
    3
    Hi

    Thanks for your reply.

    Pardon me for my understanding but I am not able to find the controls for AWSD or UP,Down,Left, Right in any of the scripts

    Rest of the keys like R, M, N , Space I can see in the scripts.

    Thanks
     
  26. bcman

    bcman

    Joined:
    Feb 9, 2013
    Posts:
    139
    Oh, I see.

    So, if you mean standard controls it's made by Unity's build-in wheelCollider's methods: steerAngle, motorTorque and so on:
    https://docs.unity3d.com/Manual/WheelColliderTutorial.html
    https://docs.unity3d.com/ScriptReference/WheelCollider.html

    So, find strings with "Horizontal" and "Vertical" words. it's reading data from Unity's AWSD keys by build-in methods.
    For example, script keyboardControls.cs, string:
    outsideControls.Horizontal = Input.GetAxis("Horizontal");
    right here we reading "A" and "D" keys to turning the bicycle.
     
  27. rohitjayakaran

    rohitjayakaran

    Joined:
    Apr 24, 2015
    Posts:
    3
    Hi thanks for your reply.

    On our project we have connected a speedometer to a bike on stand and taking the input to the pc via Arduino Yun.

    Every time wheel completes a rotation, it sends a W key to the computer. I am capturing the W key and trying to increase the speed of the rigid bike.

    So I changed the code in Keyboardcontroller.cs update method.

    if(Input.GetKey (KeyCode.W)){
    CurrentTime = milliseconds;
    CurrentDistance = 210.0f;//circumference of bike wheel
    CurrentSpeed = CurrentDistance / (CurrentTime-LastTime);
    outsideControls.Vertical = CurrentSpeed*10;
    if(outsideControls.Vertical > 1){
    outsideControls.Vertical = 0.899f;
    }

    LastTime = CurrentTime;
    CurrentTime = 0.0f;
    }
    milliseconds = (int)(Time.timeSinceLevelLoad * 1000f) ;


    But I am not able to increase the speed of the bike. It is jerky and not able to go fast while I ride the bike.
     
  28. bcman

    bcman

    Joined:
    Feb 9, 2013
    Posts:
    139
    Isn't it better to send already 'legs's power' variable from arduino ?

    Calculate it by arduino and send to com.port only power float 0.0-1.0. That's much more naturally when you send how much power user applies to pedals.
     
  29. twiggyash

    twiggyash

    Joined:
    Nov 7, 2013
    Posts:
    45
    Hi, I really would like to buy this asset but I'm still using Unity 4.7.2 in my project and can't upgrate to Unity 5. Is possibile to have a compatible version of this asset with Unity 4? Thanks a lot for help!
     
  30. bcman

    bcman

    Joined:
    Feb 9, 2013
    Posts:
    139
    Hello, twiggyash.
    That's sad but it won't work for Unity4.

    If you need two wheel vehicle I have motorcycle kit for Unity4. But's it's motorized bike not classic bicycle :(
     
  31. twiggyash

    twiggyash

    Joined:
    Nov 7, 2013
    Posts:
    45
    Thank you for reply. Ok, so your asset "Sport Bike Pro" does work with Unity 4.7?
     
  32. bcman

    bcman

    Joined:
    Feb 9, 2013
    Posts:
    139
    The asset on AssetStore "as is" is not compatible with Unity4.
    But after you bought it, I'll send you Unity4 project.
    Unity4 version contains just two bikes(without motocross).
    It's not first request for Unity4 version, so I've done this way few times with Unity4 customers.
    Give me few hours to make WebPlayer Demo to show how Unity4 version looks like.
     
  33. bcman

    bcman

    Joined:
    Feb 9, 2013
    Posts:
    139
  34. GameDveloper09

    GameDveloper09

    Joined:
    Dec 24, 2015
    Posts:
    9
    how can i add only race an reverse feature via ui buttons thank you
     
    Last edited: Aug 3, 2017
  35. GameDveloper09

    GameDveloper09

    Joined:
    Dec 24, 2015
    Posts:
    9
    is there any body who can help me in making brake and reverse function?
     
  36. bcman

    bcman

    Joined:
    Feb 9, 2013
    Posts:
    139
    What you want to do ? make UI button to reverse ?
     
  37. GameDveloper09

    GameDveloper09

    Joined:
    Dec 24, 2015
    Posts:
    9
    when i press race button cycle should drive and when i press reverse then it should move reverse. i do not want reverse button function and rearbrake function. thank you for your respond
     
    Last edited: Aug 3, 2017
  38. bcman

    bcman

    Joined:
    Feb 9, 2013
    Posts:
    139
    oh... sounds quite crazy :)
    Don't you mind to change brake button to motor torque with -power ? :)
     
  39. GameDveloper09

    GameDveloper09

    Joined:
    Dec 24, 2015
    Posts:
    9
    can you give me a favor to write function for this i am using event trigger (pointer down and pointer up)
    i am doing this for acceleration
    public void brakeclickeddown(float brake){

    outsideControls.Vertical = brake*0.5f;
    }
    and onpointerup brake value is 0 and onpointerdown brake value is 1
    and for brake i am passing 0 and -1 for the same
    accelration is working but brake stops the cycle but it does not reverse the cycle
     
    Last edited: Aug 4, 2017
  40. bcman

    bcman

    Joined:
    Feb 9, 2013
    Posts:
    139
    I'll answer you by conversation system.
     
  41. GameDveloper09

    GameDveloper09

    Joined:
    Dec 24, 2015
    Posts:
    9
    ok thank you
     
  42. JimRoot

    JimRoot

    Joined:
    Sep 11, 2013
    Posts:
    77
    6 months later still javascript...
     
  43. afasdfasf

    afasdfasf

    Joined:
    Oct 7, 2017
    Posts:
    10
    Hi! How many triangles for this?
     
  44. bcman

    bcman

    Joined:
    Feb 9, 2013
    Posts:
    139
    I'm planing to finish C# in 2017 but have no any progress yet.

    afasdfasf, what you mean ? Triangles of which part ?
     
  45. afasdfasf

    afasdfasf

    Joined:
    Oct 7, 2017
    Posts:
    10
    triangle for total. I want to know since I might use it for VR game so it should be low poly.
     
  46. afasdfasf

    afasdfasf

    Joined:
    Oct 7, 2017
    Posts:
    10
    bcman, I need your reply!!
     
  47. bcman

    bcman

    Joined:
    Feb 9, 2013
    Posts:
    139
    I've never counted triangles :)
    yes, it's lowpoly and I think there is under 10.000 triangles for rider and bike both.
    Why it's so bothering you in case of VR ? The polycount doesn't matter for moder device.
    PC cards easy plays 120fps with more than 3million triangles.
    And mobile can eat 300.000 triangles with 60fps.
     
  48. helloworldgames

    helloworldgames

    Joined:
    Mar 16, 2017
    Posts:
    60
    Hi, why video shows tires going inside floor? is it being updated
     
  49. krotovd

    krotovd

    Joined:
    Sep 23, 2014
    Posts:
    35
    Hi Boris, first would like to thank you for putting together such a nice asset. I currently am having an issue when bringing the rigid_bike prefab into my world and just wanted to know if you had seen anything like this in the past and maybe had a solution. I currently am just wanting the bike rider to follow along a path I have created. This is for a virtual reality project I have been asked to work on and I am using your asset to give the user the feeling of being on the bike. When I drag the prefab into the world I am seeing errors in the js scripts. I am doing this all in 2017.2.1f1. I have provided a screenshot below. Any ideas on why I might be seeing this. When I created an empty project and just open your scene, I don't seem to have the issue. I'm looking into this further, but just thought I'd reach out to see if you had any ideas.

    Thanks again
    Dan

    upload_2017-12-30_7-47-41.png
     
  50. krotovd

    krotovd

    Joined:
    Sep 23, 2014
    Posts:
    35
    Well seems the resolution was simple. I created a new gameobject and had the controlhub script in it but I never renamed it to "gameScenario". I didn't know I MUST do this. It resolved the issue. I am now seeing errors around variable poi01 not being assigned so going to go read the docs a bit more to see if there is a resolution for this, but I wanted to post the answer here in case anyone else ran into the same thing in the future.