Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Need help filling in code C# using UnityEngine; using System.Collections; public class WeightScript : MonoBehaviour { // The weight of this item (by itself) public

Need help filling in code C# using UnityEngine; using System.Collections; public class WeightScript : MonoBehaviour { // The weight of this item (by itself) public float weight; // Whether or not this is a container/crate public bool isContainer; // Recursively calculate the weight of the object public float CalculateWeight() { // If this is NOT a container, just return your weight // Otherwise // 1) Print out your name "this.name" // 2) create a "totalWeight" variable and assign it your weight // 3) Loop through all the (child) transforms for this object // 3.1) call the child's CalculateWeight() method and add it to the totalWeight // 3.2) It's a good idea to print out the tag of this object as well as the weight // 4) return the totalWeight // Remove the line below - it's just there to compile return this.weight; } }

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Concepts

Authors: David Kroenke, David Auer, Scott Vandenberg, Robert Yoder

10th Edition

0137916787, 978-0137916788

More Books

Students also viewed these Databases questions

Question

=+management system of the MNE?

Answered: 1 week ago