From 46e1cf9b608e13b565901c3d28a2cef6e24afc1e Mon Sep 17 00:00:00 2001 From: Chris Langsenkamp Date: Mon, 26 Aug 2019 22:56:41 -0400 Subject: [PATCH] Added notes to ChildObject Doc --- doc/articles/Concepts/GameObjects/ChildObjects.md | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/doc/articles/Concepts/GameObjects/ChildObjects.md b/doc/articles/Concepts/GameObjects/ChildObjects.md index 8b2e8082b..75f9ade32 100644 --- a/doc/articles/Concepts/GameObjects/ChildObjects.md +++ b/doc/articles/Concepts/GameObjects/ChildObjects.md @@ -10,11 +10,15 @@ Let's start with the simple case of a single attachment point, called `RightHand In the image below, I've created a simple player capsule with an arm and hand, and I've made some prefabs to be equipped (Ball, Box, Cylinder) and a Player Equip script to handle them. -**NOTE**: The item prefabs are *art only*...they have no scripts, and they *must not* have networking components. They can have monobehaviour-based scripts, of course, which can be referenced and called from ClientRpc's on the player prefab. +**NOTE**: The item prefabs are *art only*...they have no scripts, and they *must not* have networking components. They can have monobehaviour-based scripts, of course, which can be referenced and called from ClientRpc's on the player prefab. ![Screenshot of Player with Equip Script](ChildObjects1.PNG) -Here's the Player Equip script to handle the changing of the equipped item: +Below is the Player Equip script to handle the changing of the equipped item, and some notes for consideration: + +- While we could just have all the art items attached at design time and just enable / disable them based on the enum, this doesn't scale well to a lot of items and if they have scripts on them for how they behave in the game, such as animations, special effects, etc. it could get ugly pretty fast, so this example locally instantiates and destroys instead as a design choice. + +- The example makes no effort to deal with position offset between the item and the attach point, e.g. having the grip or handle of an item align with the hand. This is best dealt with in a monobehaviour script on the item that has public fields for the local position and rotation that can be set in the designer and a bit of code in Start to apply those values in local coordinates relative to the parent attach point. ``` cs using UnityEngine;