Question

In: Computer Science

View the following C# Script carefully. Assume that the Script is enabled, is attached to an...

View the following C# Script carefully. Assume that the Script is enabled, is attached to an active GameObject, and addresses the appropriate namespaces first. Discuss when and how often during the game the Update() function will be executed. Discuss each line (from line 9 to 17, excluding the lines with curly brackets) to detail what the code inside the update function is doing. Be sure to outline how the variables are being used during your discussion. 1 public class Player : MonoBehaviour 2 { 3 public GameObject coinPrefab; 4 private GameObject coin; 5 public Transform spawnpoint; 6 7 void Update() 8 { 9 if (Input.GetMouseButtonDown(0)) 10 { 11 Instantiate(coinPrefab, spawnpoint.position, spawnpoint.rotation); 12 } 13 if (Input.GetMouseButtonDown(1)) 14 { 15 coin = GameObject.FindWithTag("Coin"); 16 Destroy(coin); 17 } 18 } 19 }

Solutions

Expert Solution

code:-

using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using UnityEngine.UI;
using someNamespace;

1 public class Player : MonoBehaviour
2 {
3   public GameObject coinPrefab;
4  private GameObject coin;
5   public Transform spawnpoint;
6  
7   void Update()
8  {
9      if (Input.GetMouseButtonDown(0))
10     {
11         Instantiate(coinPrefab, spawnpoint.position, spawnpoint.rotation);
12     }
13      if (Input.GetMouseButtonDown(1))
14     {
15        coin =  GameObject.FindWithTag("Coin");
16         Destroy(coin);
17     }
18  }
19 }


Related Solutions

View the following C# Script carefully. Assume that the Script is enabled, is attached to an...
View the following C# Script carefully. Assume that the Script is enabled, is attached to an active GameObject, and addresses the appropriate namespaces first. Discuss when and how often during the game the Update() function will be executed. Discuss each line (from line 9 to 17, excluding the lines with curly brackets) to detail what the code inside the update function is doing. Be sure to outline how the variables are being used during your discussion. 1 public class Player...
I have attached the following script file Q1) List the full name of members, their DETAIL_DAILYLATEFEE...
I have attached the following script file Q1) List the full name of members, their DETAIL_DAILYLATEFEE and the average of DETAIL_DAILYLATEFEE for all members whose DETAIL_DAILYLATEFEE is less than the average of all DETAIL_DAILYLATEFEE. Your query MUST contain a subquery. Your result should be as shown below. Note that each member is only listed once. Required: AVG(DETAIL_DAILYLATEFEE) CONCAT DISTINCT Restricted: GROUP BY Q2) Management is also interested in finding out the age of their movies (i.e. how old the movies...
Please read the instructions and  find attached for the first wiki . Instructions for students: Read carefully...
Please read the instructions and  find attached for the first wiki . Instructions for students: Read carefully the attached document and then post your comments bearing in mind the following questions: 1- What are the pros and cons of rent controls? 2- Why economists disagree on the usefulness of rent control? 3- Do you believe rent control can help the poor? Edit Wiki Content rent control Rent regulation can take various forms, including rent control (the placing of a cap on...
Introduction to Public Health Read the attached document and view the short video. Determine why it...
Introduction to Public Health Read the attached document and view the short video. Determine why it is related to chapter 3. (Public Health Data and Communications) Explain how health communication influences behavior change (s). Feel free to investigate other resource (citation needed) to expand understanding and explanations.
Calculate the following based on 2018 numbers using the attached financial statements for XYZ Corp. Assume...
Calculate the following based on 2018 numbers using the attached financial statements for XYZ Corp. Assume the only variable cost is the cost of goods sold. Survival revenues (EBITDA breakeven – includes interest). B.NOPAT Breakeven c) Interpret these values and indicate what you would expect to happen to them if a large addition is made to fixed assets. Financial Statements for XYZ Corp. Balance Sheet for Period Ending December 31. Assets 2017 2018 Cash and Marketable Securities 40 15 Accounts...
Lab 11 C++ Download the attached program and run it - as is. It will prompt...
Lab 11 C++ Download the attached program and run it - as is. It will prompt for a Fibonacci number then calculate the result using a recursive algorithm. Enter a number less then 40 unless you want to wait for a very long time. Find a number that takes between 10 and 20 seconds. (10,000 - 20,000 milliseconds). Modify the program to use the static array of values to "remember" previous results. Then when the function is called again with...
3.1. Carefully explain the following observations: (i) Silver dissolves poorly in copper at 100°C. (ii) Copper...
3.1. Carefully explain the following observations: (i) Silver dissolves poorly in copper at 100°C. (ii) Copper dissolves poorly in silver at 100°C. (iii) The amount of copper (in atom per cent) that can dissolve in silver at 100°C is greater than the amount of silver (in atom per cent) that can dissolve in copper at 100°C.
USE C# to write this. 1.To the capsule, add a script called “MoveIt”. This will make...
USE C# to write this. 1.To the capsule, add a script called “MoveIt”. This will make the capsule move repeatedly between (3, 0, 0) and (-3, 0, 0), moving 1 unit per second, moving in the positive direction initially. [Note: The capsule should move toward (3,0,0) from its initial location of (0,1,0) and then move toward (-3,0,0), etc.] 2.To the yellow cube, add a script called “RotateIt”. This will make the cube rotate (30, 60, 90) per second. 3. Lastly,...
Assume the vector AM contains an even number of elements. Develop a MATLAB script that asks...
Assume the vector AM contains an even number of elements. Develop a MATLAB script that asks the user for the vector AM and once the vector is found to contain an even number of elements, divide the product of its even elements by the sum of its odd elements without using the MATLAB functions prod or sum. Store the result in a variable called PDS. If AM is found to contain an odd number of elements, display an error message...
Name the script while.sh. Ask the user to enter a positive integer. You can assume that...
Name the script while.sh. Ask the user to enter a positive integer. You can assume that the user will enter a positive integer (input validation for a positive number not required). Use a while loop to print all integers from 0 up to and including the integer entered. Each integer should be printed on a line by itself and nothing else should print. This is for Linux. I have not done anything on this script. Please help with simplistic commands...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT