Author Topic: Dynamic Prefabs with Tasharen  (Read 3880 times)

Xi4

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 2
    • View Profile
Dynamic Prefabs with Tasharen
« on: October 02, 2014, 11:57:38 AM »
Hello everybody,

I am currently working on a online racing game and I reached the point where I want to choose a solution for networking.
My most important question is, is Tasharen able to spawn a character with settings?
Like, I spawn a player, but he has (depending on ID saved) a different hat than others, or a different skin.

I hope someone can answer my question. :)

Greetz,
Xi4.

MCoburn

  • Jr. Member
  • **
  • Thank You
  • -Given: 1
  • -Receive: 7
  • Posts: 69
    • View Profile
Re: Dynamic Prefabs with Tasharen
« Reply #1 on: October 02, 2014, 11:07:24 PM »
EDIT: I read 'character' as 'car'. Why the heck did I do that for?!  ???

Here's one way of doing it:

Spawn a prefab of a generic car, or all the cars and everything packed into one prefab. Have it under nested GameObjects, like:

  1. DragCar
  2. -- V12 SuperCharger
  3. ---- Body
  4. ---- Decals
  5. -- V8 Turbo Diesel
  6. ---- Body
  7. ---- Decals
  8. <etc>
  9.  

Have a script attached to it that checks what the player settings are (ie. decals, Nitro, exhaust, paint job, etc) and enable/disable the child game objects depending on what the car has.
You might get a minor performance hit but since the script will kick in ASAP, the player shouldn't notice a big black box thing as the car is customized.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Dynamic Prefabs with Tasharen
« Reply #2 on: October 02, 2014, 11:26:58 PM »
My most important question is, is Tasharen able to spawn a character with settings?
Sure. Pass custom parameters alongside your create call: http://www.tasharen.com/forum/index.php?topic=5416.0

Xi4

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 2
    • View Profile
Re: Dynamic Prefabs with Tasharen
« Reply #3 on: October 03, 2014, 01:28:43 AM »
Thanks for your answers.
I'll use cars too, so your answer helped a lot.
There is no generic car since they're multiple types of cars available, but I guess I'll just make empty prefab and disabled all childs by default and only enable the one I need.