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] PUN Rally

Discussion in 'Assets and Asset Store' started by perick, Dec 1, 2015.

  1. chrisabranch

    chrisabranch

    Joined:
    Aug 15, 2014
    Posts:
    146
    did anyone get this to work with Realistic Car Controller? if you did or know how can you help me, im willing to pay for your time.
     
    99thmonkey likes this.
  2. perick

    perick

    Joined:
    Jun 20, 2008
    Posts:
    235
    Does realistic car controller has a free version? I might give it a try and send you updated prefab.
     
  3. perick

    perick

    Joined:
    Jun 20, 2008
    Posts:
    235
    Guys,

    I made PUN Rally work with Edy's Vehicle Physics 5 in less than 30min. I did a couple of modifications on some scripts to make it easier to adapt ANY other pack as well (this will come with update 1.0.5).

    I published a video explaining the process used here:
    Adding Edy's Vehicle Physics to PUN Rally

    But a summary is:
    - Replace one of the prefabs in the Resources folder for the car prefab you want (it does have to rely on e Rigidbody);
    - Add the following scripts to the prefab: NetworkCar, PhotonView, CarRaceController CarGUI, and CustomCarInput (this is the only custom script you'll after getting the new versions of CarGUI and CarInput);
    - Set PhotonView to observe Network car (as in other prefabs), and disable the CarInput (and controlable attribute) - they'll be enabled from code in the PunRaceControl script;

    That's it... Have a different car pack working in pun rally...

    Even the car damage stuff from Edy's is working (though this part is not exactly synchronized - this would be another story)...:)

    I included here the modified versions of CarInput, CarGUI (both will come with 1.0.5) and the custom input script (CarInputEVP5.cs) I did specially for Edy's pack (take a look at it to create one for other packs) - please SEE THE VIDEO before using these scripts.

    The modified version of CarInput basically creates two methods to separate input lookup (from player) from input application on car controller, so inherited versions of CarInput can replace any of the two independently (I had to replace input application only for Edy's physics);

    The CarGUI mod was just to get rig of a dependency to Standard's car controller. Now CarGUI gets the car speed straight from the Rigidbody (it does have it's drawbacks, but it is more flexible for you guys to adapt different car physics packs into PunRally);
     

    Attached Files:

  4. perick

    perick

    Joined:
    Jun 20, 2008
    Posts:
    235
    Just to register here that, after some 3 to 4h of work (including the work on Edy's physics) I did make Realistic Car Controller (V2) work with PUN Rally (with some minor issues, but Chris got a couple of scripts and some directions on what to do next);

    My opinion: the car behaviour with realistic car controller is nice (good torque curve modeling, nice gear change delays, etc), but the code is a complete mess, and I wouldn't use it in a game because of this... A single script handles input, gui, mobile, physics, fx, audio, ads and the kitchen sink (FYI).
     
  5. chrisabranch

    chrisabranch

    Joined:
    Aug 15, 2014
    Posts:
    146
    thank you :) your very helpful
     
  6. 99thmonkey

    99thmonkey

    Joined:
    Aug 10, 2012
    Posts:
    525
    What about WebPlayer and WebGL?
     
  7. 99thmonkey

    99thmonkey

    Joined:
    Aug 10, 2012
    Posts:
    525
    Please share. I like Realistic Car Controller best. I use it all the time.
     
  8. perick

    perick

    Joined:
    Jun 20, 2008
    Posts:
    235
    I haven't tested but it should work the way it is... There's nothing special going on.
     
  9. perick

    perick

    Joined:
    Jun 20, 2008
    Posts:
    235
    Here it is (the two updated classes CarInput and CarGUI, and the special CarInputRCC to be used on RealisticCarControllerV2).

    Remember a few things:
    - To create the prefab, follow the same approach as shown in the video about Edy's Vehicle Physics (linked in the first post) - except you neither need to remove an RCC input script (there's none) nor include CarGUI (RCC takes care of this);
    - Remember that this is a very simple support for RCC's most basic features (haven't been tested on mobile, etc): there's a lot that should be done to completely synchronize what RCC does, such as gear changes, engine start, and any other specific/novel state variable that RCC has. This would require changes in the NetworkCar script as well, and it'd be very dependent ou your specific needs;
    - This version here doesn't start the engines automatically, and has an issue with the brake/gear changes (thought Chris knows how to do it - I don't own RCC personally, so thanks to him for having shared a project so I could help a bit);

    Being this a community, I'd encourage you guys to share here the experiences you had adapting PUN Rally code to work with these different car physics packs (I'd be happy to provide a link with a simple guide and the credits for those of you who share the developed versions of these bridge-like scripts).

    Maybe I can try to contact the creators of the most used car physics packs (lets say Edy's + 2 more) and try to get their help into adapting our network code to work with their packs - and then we might share a pack of classes that are tested officially). Being this not guaranteed neither by me nor by them, I'd first try to share your experiences.

    I believe in one month or so we'll all have this sorted out and stable for these different packs. I still highly encourage you guys to read the PDF tutorial again. There's very valuable information there, which is important for those of you who need to modify our scripts to completely support your own game specific features.

    And of course, being this a public forum, I won't share here classes that are part of the pack (the updated CarInput is an exception because 1.0.5 has to wait until Jan - all other updates will be sent via the asset store). Remember that the PDF tutorial is free (links in the first post).
     

    Attached Files:

    Last edited: Dec 29, 2015
    NeoUnity likes this.
  10. NeoUnity

    NeoUnity

    Joined:
    Sep 4, 2013
    Posts:
    156
    Anyway, This is only my checking on Asset advertising words. I can't discover any words for mobile on Edy's Vehicle Physics.
    - RCC (Realistic Car Controller) : "Each car controller takes only %1 ~ %1.5 CPU power on empty prototype scene, which is extremely good for mobile devices!"
     
  11. perick

    perick

    Joined:
    Jun 20, 2008
    Posts:
    235
    Yes, I believe it works fine on mobile (remember reading this in the description for the version I got). I guess most car physics packs are light enough to work on mobile.

    But anyway, I have no connection to Edy (just happen to have bought his asset a while ago, and I liked it), so I want to make sure PUN Rally works with as many packs as possible. It may just take a while. Firstly I need to concentrate on the features requested for PUN Rally itself, and finish the videos...:)
     
    antoripa and NeoUnity like this.
  12. NeoUnity

    NeoUnity

    Joined:
    Sep 4, 2013
    Posts:
    156
    "AntiRollBar" is only JavaScript. Can i convert it to C# without problems? I need it inactive on runtime.
     
  13. NeoUnity

    NeoUnity

    Joined:
    Sep 4, 2013
    Posts:
    156
  14. perick

    perick

    Joined:
    Jun 20, 2008
    Posts:
    235
    Yes, you can. It is a script that is in public domain, found here in the forums.
     
  15. perick

    perick

    Joined:
    Jun 20, 2008
    Posts:
    235
    1.0.5 will come with mobile controls enabled (it is implemented and tested here, just awaiting for the Photon guys to come back from the holidays).

    Please take a look at the cross platform input examples in Unity 5. They're very easy to understand and extend. You don't need to buy an asset for this.
     
  16. NeoUnity

    NeoUnity

    Joined:
    Sep 4, 2013
    Posts:
    156
    Thanks for your kindly reply:)
     
  17. chrisabranch

    chrisabranch

    Joined:
    Aug 15, 2014
    Posts:
    146
    perick got it 99% working for me. when i get it to %100 i'll send you a message
     
    antoripa likes this.
  18. perick

    perick

    Joined:
    Jun 20, 2008
    Posts:
    235
    Please share ii here in the forum. It's good for others who get into the same issue. I've already shared the "99%" here.
     
  19. chrisabranch

    chrisabranch

    Joined:
    Aug 15, 2014
    Posts:
    146
    Hey ,
    I have a menu in the single player part of my game to choose cars, lock and unlock system using playerprefs.
    i don't want the player to use cars they have not unlocked in multiplayer. i was thinking of making a script , some thing like:

    if the playerpref key is not unlocked for the car then the multiplayer cant choose that car. problem is , i don't understand this.....

    public void NextCar() {
    carIndex = (carIndex + 1) % carTextures.Length;
    SetCustomProperties (PhotonNetwork.player, carIndex, (int) PhotonNetwork.player.customProperties ["spawn"]);
    }

    public void PreviousCar() {
    carIndex--;
    if (carIndex < 0)
    carIndex = carTextures.Length - 1;
    SetCustomProperties (PhotonNetwork.player, carIndex, (int) PhotonNetwork.player.customProperties ["spawn"]);
    }



    • where is the carindex?
    • do the cars have int value in order?
    can someone help me? i'm sure almost every car will have a lock car system , there may be others with same problem.
     
  20. perick

    perick

    Joined:
    Jun 20, 2008
    Posts:
    235
    You won't be able to use all scripts "as they are" if you already have a working game, that use your own forms of organizing the prefabs and instantiations, etc. You'll need to modify this for what you need. Here's a suggestion:

    - If you want to use the same approach and most of the code I did, have your car prefabs in order such as in my example;
    - Have all the "unlocked" cars indexes as keys n a dictionary (or store them in a collection or something);
    - Change the methods nextCar and PreviousCar to skip/bypass any carIndex that corresponds to a car that is still locked in the playerPref of that player. carIndex is an attribute in this script.

    It might work like this, if you do the rest as I suggested:

    Code (CSharp):
    1. public void NextCar() {
    2.    carIndex = (carIndex + 1) % carTextures.Length;
    3.    while (!unlockedCars.ContainsKey(carIndex)) {
    4.       carIndex = (carIndex + 1) % carTextures.Length;
    5.    }
    6.    SetCustomProperties (PhotonNetwork.player, carIndex, (int) PhotonNetwork.player.customProperties ["spawn"]);
    7. }
    Do something similar for PreviousCar().

    You might even want to modify the prefab instantiation and use a prefab name from this unlockedCars dictionary, etc. There are many options to choose from. It's up to you what approach to follow.
     
  21. chrisabranch

    chrisabranch

    Joined:
    Aug 15, 2014
    Posts:
    146
    How d
    i like this option , i just don't understand how/ where photon does prefab instantiation.
     
  22. perick

    perick

    Joined:
    Jun 20, 2008
    Posts:
    235
    It's in PUNRaceManager... Please read the Tutorial PDF and look at the code. You need to understand what it does, so you can adapt it to your game.

    Are you a programmer?
     
  23. chrisabranch

    chrisabranch

    Joined:
    Aug 15, 2014
    Posts:
    146
    im still learning to program, self taught
    the game im making will not be released im making it to learn photon
    one day i can quit my day job :)
     
    Last edited: Dec 31, 2015
    perick likes this.
  24. perick

    perick

    Joined:
    Jun 20, 2008
    Posts:
    235
    The prefab instantiation is done by the method PhotonNetwork.Instantiate(...). Take a look at the method CreateCar in the class PUNRaceManager.cs. I do the prefabs inntantiation there. It is explained in the Tutorial PDF as well...

    When you're in doubt about some concept, try to look in Unity's documentation as well. It is pretty good...:)
     
  25. 99thmonkey

    99thmonkey

    Joined:
    Aug 10, 2012
    Posts:
    525
    Do you think I would be able to learn from your pack and adapt it so that I can enter and exit the vehicles and still have them synced over the network? I'm thinking that I can learn from how you put together the Multiplayer cars, plus integrate it with an adventure game so I can exit the car, walk around, and then get in another car and other players are doing the same thing. Or is this too far fetched?
     
  26. perick

    perick

    Joined:
    Jun 20, 2008
    Posts:
    235
    You might use our code to sync the cars when the player is inside one (there are many forum posts with code to accomplish the in/out feature). I'd disable the sync for cars if there're no players in it (but it depends on how you want the car to behave with no player - is there an AI?).

    So, the short answer is: it would be useful, but you'd need a lot more to have what you want.

    Specially if you want many many players in a single match... In don't want to discourage you, just try this an a couple of other tutorials before getting into doing a game like that.

    This is what a complete project/tutorial is: a project template that teaches you something... It's not supposed to have code snippets to glue on other projects...:)
     
  27. 99thmonkey

    99thmonkey

    Joined:
    Aug 10, 2012
    Posts:
    525
    Im a bit confused by your response. Thank you for taking the time to respond. i do know the difference between a template and a complete project.
     
  28. NeoUnity

    NeoUnity

    Joined:
    Sep 4, 2013
    Posts:
    156
    Last edited: Jan 4, 2016
  29. perick

    perick

    Joined:
    Jun 20, 2008
    Posts:
    235
    What I meant is:

    PUN Rally is perfect if you're starting a new game project, that is designed from the beginning. It is a complete project (a simple working game, but with source code, comments and a tutorial in PDF). Being a complete/working game, it already has some decisions/compromises made on how to do some things - and this makes it a bit more difficult to use parts of the code in existing projects. On the other hand, think about any standalone pack, for instance: this type of asset (physics pack, 3d models, shaders) is designed to be included in an existing project;

    A template is a project skeleton, which can be used to create a complete game by modifying and adding stuff to it. So PUN Rally can be seen as a template as well.
     
  30. perick

    perick

    Joined:
    Jun 20, 2008
    Posts:
    235
    Thanks for the suggestion.

    I'm not sure this is in the scope of our project, but I do have interest in this thing. I've done racing AIs in the past, an I have an interesting approach:
    - Use as many checkpoints as possible (fine grained, auto-generated by recording a run at the track, creating checkpoints every second or so);
    - Also record the speed the sample drivers use in each of these checkpoints (use several runs to have a mean, max an min velocity for each checkpoint/speed trap);
    - Write an AI script with a control system (much like any cruise control) that tries to maintain the desired speed along the track (based on the next checkpoint) - this will make it try to get to the right speed even if in the middle of a pack, or after a spin - no need for braking and accel zones);

    I write overtaking AI separately from the normal cruise/steering AI. I make it override the controls when there's is safety for this (a straight, etc);

    It is quite a challenge to write good racing AI. I like the online articles on Microsoft's Drivatars (Forza series).
     
    antoripa and NeoUnity like this.
  31. perick

    perick

    Joined:
    Jun 20, 2008
    Posts:
    235
    New about update 1.0.5:

    Just sent the update to the guys at Photon Engine. It will be online on the asset store later today. Here's a copy of the change-log, with everything that went in:

    • Car physics tweaks for improved stability and control easyness;
    • Mobile controls (accell and brake as screen buttons and tilt steering);
    • Track selector with three tracks (two new): master client can choose tracks, while the others can see which track is being selected in realtime;
    • Auto-unflip car (dot product based upside-down detection + auto unflip - good for mobile);
    • Wrong way computation (also dot product based);
    • Updated PDF Tutorial (1.0.5);
    • All tracks now have a start/finish mark;
    • New CarInput class separates input gathering from application on car in different methods, making it suitable for inheritance (check the online forums to get sub-classes that act as bridges for other car physics packs such as Edy's Vehicle Physics and Realistic Car Controller);

    TODO for 1.0.6:
    - Auto-numbering of players with equal nickname;
    - Esc or back button;
     
    stvster, NeoUnity and Andreas12345 like this.
  32. chrisabranch

    chrisabranch

    Joined:
    Aug 15, 2014
    Posts:
    146
    nice, update.

    how would a make a private room option, under a password?
    and 1.0.6 request : lobby chat room
     
  33. perick

    perick

    Joined:
    Jun 20, 2008
    Posts:
    235
    A private room with password is very easy to do: just create appropriate input fields for password and use the methods described in the Photon documentation (room properties). I don't think we're going to put something like this in PUN Rally because it's been well documented everywhere, and it'd just clutter the project with too many options.

    Room chat might be more interesting for a future release.

    BTW: we're working on a new VR multiplayer project where we think we'll have voice chat over photon...:)
     
    NeoUnity likes this.
  34. chrisabranch

    chrisabranch

    Joined:
    Aug 15, 2014
    Posts:
    146
    ll be the first to buy it, is there a beta or alpha i can buy now?
     
  35. stvster

    stvster

    Joined:
    Mar 4, 2013
    Posts:
    70
    THANX for the update to version 1.0.5. Very nice additions.I tested the previous version with friends across the country and it worked great. Version 1.0.5's new additions are awesome.Well Done!
    Happy New Year all,
    Steve
     
  36. perick

    perick

    Joined:
    Jun 20, 2008
    Posts:
    235
    Not yet, but as soon as we have a forum thread for it I'll post a link here for you guys to suggest features you'd like to see included (we already have a proposal and we're working on the prototype).

    It's going to see a scripted transport mission where you play the gunner in the freighter, protecting it (and the cargo) from incoming fighters, etc.

    A taste of it (we'll tell more when we have a planned release and publish it in the forum):

    - You'll be able to play with VR or on a regular 3D setup (no VR);
    - You'll aim with gaze on VR and with mouse without it;
    - Multiple gunners (cooperative multiplayer) in a single freighter and multiple freighters (all coop);
    - Voice/radio chat between the team;
    - Scripted mission from mined asteroid to space dock (~5min) with lots of gun action;
    - Survive to win and see statistics for better gunners, etc;
    - All 3D art, particle fx and music will be royalty free as well, of course;

    All done with Photon Free...
     
    stvster and NeoUnity like this.
  37. perick

    perick

    Joined:
    Jun 20, 2008
    Posts:
    235
    Thanks for buying the pack. Please show us when you have your modifications working. I'd love to see different racing games based on this...
     
    stvster likes this.
  38. perick

    perick

    Joined:
    Jun 20, 2008
    Posts:
    235
    A quick note about update 1.0.6: A user contacted us from our website and asked for a solution for the end-race winner/positions to stay and show correctly. We'll include it for 1.0.6 (no estimated release date yet). Here is what we intend to develop now:

    • Auto-numbering of players with equal nickname;
    • Esc or back button;
    • end-of-race positions/winner;
     
    Andreas12345 likes this.
  39. Andreas12345

    Andreas12345

    Joined:
    Oct 17, 2013
    Posts:
    526
    Hey Perick, great job so far. :)
    Do you think we can buy some ad ons later?
    Like i wrote in my review: a funny power up / weapons system like re-volt.
     
    NeoUnity likes this.
  40. perick

    perick

    Joined:
    Jun 20, 2008
    Posts:
    235
    Hi Andreas,

    I love revolt and it'd be awesome if somebody could revisit the concept.

    I've been thinking about a powerups and simple weapon system for a future major update indeed. Not promising for the next one, but the idea is written and I want to do it.
     
  41. Andreas12345

    Andreas12345

    Joined:
    Oct 17, 2013
    Posts:
    526
    i try my very best to give you a concept for it @ the weekend.
    Post here or PM?
     
  42. oneru220

    oneru220

    Joined:
    Oct 20, 2013
    Posts:
    3
    perick likes this.
  43. perick

    perick

    Joined:
    Jun 20, 2008
    Posts:
    235
    It's not a bug, it's just that you're doing only for the local copy of the instantiated prefab. If you modify a game object (apply a color on a shader, for instance), you're doing it only for the local copy. Anything you want to change on the remote copies you'd have to send over Photon (by the means of an either an RPC or a custom player property).

    When a prefab is instantiated (and replicated by photon), it'll be created with it's stored values only. If you're applying the RGB values as a tint on the main shader for the local prefab (inside the method createCar?), you'd need to send these RGBs for all other clients to be applied on the copied instances of the car (one hint is to pass the player ID and look for the instantiated car for that player ID, and then apply the RGBs as tint).
     
  44. perick

    perick

    Joined:
    Jun 20, 2008
    Posts:
    235
    Thanks for the detailed explanation of the powerups and weapons.

    I'm sorry I can't help directly in the implementation of a Revolt remake itself (I'd love to PLAY it though). I'll keep the powerup/weapons system in our whishlist for future updates, but I won't be targeting a complete implementation of all of Revolt guns (remember I need to maintain a generic tutorial, not a specific game).

    However, please post your game ideas here in the forum, so other users might tell if they're interested in helping out. I need to keep the support for the pack itself (and the new ones we're creating).
     
  45. Andreas12345

    Andreas12345

    Joined:
    Oct 17, 2013
    Posts:
    526
    Here are the re-volt concepts If anybody interested to make an add on:
    Weapons / Poweups:
    Global Star
    ----------
    The Global Pulse is a that, when fired, emits an electromagnetic pulse on a global scale,
    temporarily disabling all other racers except for the one that fired it for about three seconds.

    Oil Slick
    ---------
    The Oil Slick is a pickup that, when used, drops a puddle of oil behind the car.
    Anyone that drives through the puddle will lose all traction on whatever wheels pass through it for a short time.
    After 30 seconds it disappears from the track.

    Bomb
    ----
    The Bomb is a Pickup that activates automatically once auto-selected. Upon activation, the player's car turns black and the antenna starts burning down like a fuse.
    The bomb takes ten seconds to explode.
    While a bomb can't be defused, the player can pass it off to other racers by touching them. The victim gains the remaining fuse time.

    Firework
    --------
    Firework is a weapon that once fired turns into a firecracker with a homing-missile style attack at the nearest car.
    A car that is being targeted is marked with a rotating, colored reticle; green if it's you, or red if it's an opponent.
    They are classified as Fireworks when they come in packs of three.



    Shockwave
    ---------
    Shockwave is a pickup that can be fired to alter the gravity of nearby objects. After firing, this weapon lifts and flips any car it comes near,
    Shockwaves will also bounce off walls to follow the track.

    Water Balloon
    -------------
    The Water Balloon is a weapon that, when fired, launches a water balloon straight forward.
    Balloons will bounce off the environment once before bursting, and will also burst on contact with other racers.
    Water balloons always come in packs of three. If not encountered by the player or bursted upon impact, they will eventually self-destruct. Slugballoon
    Water balloons lack homing capability, but can disorient racers much more than a firework.

    Electroblast
    -----------
    Electro Blast, also known as Electro Pulse, is a pickup that, once activated, covers the activator's car in electricity for 10 seconds.
    While the pickup is active, driving near another car will "zap" it, overloading its circuits and disabling it for 3 seconds.

    BallBearing
    -----------
    The Ball Bearing is a pick up that drops from the rear of the car, it is an extremely heavy ball knocking anything in it's path out of the way.
    After 30 seconds, it disappears from track.
     
  46. perick

    perick

    Joined:
    Jun 20, 2008
    Posts:
    235
    Guys, if any of you manage to create a nice original game (based on this pack or not) with Photon, please contact us or Photon directly. I believe they'd be glad to help promote games made with their infra-structure.
     
  47. Andreas12345

    Andreas12345

    Joined:
    Oct 17, 2013
    Posts:
    526
    Here are 3 level without write any line of code, i ve just used the actually PUN Rally attached 3 level, and make the car scale to 0.7. I also added in level 2 PhotonView Script to some busses and busstops, so you can see the collision over network.
    Waiting for 1.06 :)
    http://www.quakeit.de/RacerMP.zip
    Have PhUN
     
    stvster likes this.
  48. Skyfly

    Skyfly

    Joined:
    Jan 25, 2014
    Posts:
    110
    I am developing a 'car' game for VR right now. The idea was to have coop multiplayer, but I scratched that becaue of networking stuff being rocketscience. With your project multiplayer seems doable again. Can you point me into the right direction for getting a basic raycast and a basic collision-mesh weapon into multiplayer?
    Thanks!
     
  49. perick

    perick

    Joined:
    Jun 20, 2008
    Posts:
    235
    I'll include a simple weapon system (with a raycast "laser" and a rocket) in 1.0.6.

    The new VR Project we're developing will also have weapons, and it is coop, so that might help as well.

    No release date yet, because I'm getting married next saturday, but after that I'll post expected deadlines.
     
    jovino, NeoUnity, Skyfly and 2 others like this.
  50. Skyfly

    Skyfly

    Joined:
    Jan 25, 2014
    Posts:
    110
    Thanks Erick, and all the best!