First Person Shooter in Unity. I am following a tutorial that is written in Javascript, and I am trying to translate it into C#. I mostly have it all functioning, except for the "holdHeight" and "holdSide" public variables in the Inspector. I can get them to show up, but when you adjust them in Unity, they do nothing to the position of the gun. I think it's because they are not being read into the "new" Vector3 created in the first line, transform.position. Here is my C# code:
using UnityEngine;
public class GunScript : MonoBehaviour
{
public GameObject cameraObject; // Parameter for the Main Camera
Object in Unity
[HideInInspector]
public float targetXRotation;
[HideInInspector]
public float targetYRotation;
[HideInInspector]
public float targetXRotationV;
[HideInInspector]
public float targetYRotationV;
public float rotateSpeed = 0.3f; // Shows Up in Inspector But
Adjustment Does Nothing
public float holdHeight = -0.5f; // Shows Up in Inspector But
Adjustment Does Nothing
public float holdSide = 0.5f; // Shows Up in Inspector But
Adjustment Does Nothing
// Update Is Called Once Per Frame
void FixedUpdate()
{
// Assign the Camera Game Object in Unity to the Gun and Allow
Adjustment of Gun's Position
transform.position = cameraObject.transform.position +
(Quaternion.Euler(0, targetYRotation, 0) * new Vector3
(holdSide, holdHeight, 2)); // *** This Is Where I
Think The Error Is
// Allow Gun to Move in Player's "Hand"
targetXRotation = Mathf.SmoothDamp(targetXRotation,
cameraObject.GetComponent<MouseLook>().xRotation, ref
targetXRotationV, rotateSpeed);
targetYRotation = Mathf.SmoothDamp(targetYRotation,
cameraObject.GetComponent<MouseLook>().yRotation, ref
targetYRotationV, rotateSpeed);
// Allow Gun to Move With Player's "Arm"
transform.rotation = Quaternion.Euler(targetXRotation,
targetYRotation, 0);
}
}
public class GunScript : MonoBehaviour
{
public GameObject cameraObject; // Parameter for the Main Camera
Object in Unity
[HideInInspector]
public float targetXRotation;
[HideInInspector]
public float targetYRotation;
[HideInInspector]
public float targetXRotationV;
[HideInInspector]
public float targetYRotationV;
public float rotateSpeed = 0.3f; // Shows Up in Inspector But
Adjustment Does Nothing
public float holdHeight = -0.5f; // Shows Up in Inspector But
Adjustment Does Nothing
public float holdSide = 0.5f; // Shows Up in Inspector But
Adjustment Does Nothing
// Update Is Called Once Per Frame
void FixedUpdate()
{
// Assign the Camera Game Object in Unity to the Gun and Allow
Adjustment of Gun's Position
transform.position = cameraObject.transform.position +
(Quaternion.Euler(0, targetYRotation, 0) * new Vector3
(holdSide, holdHeight, 2)); // *** This Is Where I
Think The Error Is
// Allow Gun to Move in Player's "Hand"
targetXRotation = Mathf.SmoothDamp(targetXRotation,
cameraObject.GetComponent<MouseLook>().xRotation, ref
targetXRotationV, rotateSpeed);
targetYRotation = Mathf.SmoothDamp(targetYRotation,
cameraObject.GetComponent<MouseLook>().yRotation, ref
targetYRotationV, rotateSpeed);
// Allow Gun to Move With Player's "Arm"
transform.rotation = Quaternion.Euler(targetXRotation,
targetYRotation, 0);
}
}
First Person Shooter in Unity. I am following a tutorial that is written in Javascript, and...
Hey I am having trouble with this problem in C++: The first race is tomorrow! You are provided a list of race entries in the following form: vector<string> entryList = { "42, Vance Cardoza", "55, Vanessa Pandara", "36, Gaston Carlton", "99, Rich Diesel", "10, Euler Bustamente" }; In your main() function instantiate a Race object. Use a C++ iterator to walk through the entries in the list above, parse out each car number and driver name and add them to...
C# Hey I am having trouble implementing additonal function to this assignment: Problem: Implement three IComparer classes on Employee - NameComparer, AgeComparer, and PayComparer - that allow Employees to be compared by the Name, Age, and Pay, respectively. Code: Employee.Core.cs using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Employees { partial class Employee { // Field data. private string empName; private int empID; private float currPay; private int empAge; private string empSSN = ""; private string empBene...
I am almost done with this code, but for some reason I am still getting an error message: Some of the instructions were: Using a loop, prompt for a currency to find. Inside the loop that manages the input, call the lookUpCurrency() method can pass the inputted currency code value. The lookUpCurrency() method needs to loop through the list of currencies and compare the passed currency code with the code in the array. If found, return true - otherwise return...
This is my code so far for the assignment. I am stuck on the last 3 tasks which are task#3, task#4 and task#5. Task #3 String Comparisons In checkForDiscount() method of the driver: 1. Figure out if there is a discount of $2 on this order, due to the customer's name being either Mike or Diane 2. Return either 2 or 0 as the discount to the cost of the pizza 3. Compile, debug, and run. You should now be...
Question: SWAPPING NODES IN A SINGULARLY LINKED LIST: I am attempting to create a program that swaps 2 nodes (no matter where they are in the list) and am having some difficulty. I can't seem to figure out why this swap method is throwing an error. Code: (SWAPPING METHOD AND TEST LINE BOLDED) package linkedlists; public class SinglyLinkedList<E> implements Cloneable { //---------------- nested Node class ---------------- /** * Node of a singly linked list, which stores a reference to its...
This is a repost of my question from before. I am having trouble writting the code for this project. Below is the project description with various methods and classes the code in C++ should implement. Project Description The goal of this project is to design and develop C++ code and algorithms to control a bank of elevators, which services many floors and transports people “efficiently ", that is, as per the given specifications. A second goal is to effectively employ...
NOTE if the player enters an invalid choice, the computer wins by default. NOTE To generate a random choice, this code uses the Random object as we have used in the previous labs. A value of 0 will be Plant, 1 will be Water and 2 will be Fire. Note that you MUST use these assignments of numbers to types for your submission to be able to pass the test cases! NOTE You MUST only declare and instantiate one single...
In java language
here is my code so far! i only need help with the extra credit
part
For this project, you will create a Rock, Paper, Scissors
game.
Write a GUI program that allows a user to play Rock, Paper,
Scissors against the computer.
If you’re not familiar with Rock, Paper, Scissors, check out the
Wikipedia page:
http://en.wikipedia.org/wiki/Rock-paper-scissors
This is how the program works:
The user clicks a button to make their move (rock, paper, or
scissors).
The program...
I am doing an Arduino Uno project where I made a "Simon says" memory game with 3 neopixel LED strips and 3 - ultrasonics. I have them working independently but I need to combine the code so they work together. Here is what I have: Memory Game #define PLAYER_WAIT_TIME 2000 // The time allowed between button presses - 2s byte sequence[100]; // Storage for the light sequence byte curLen = 0; // Current length of the sequence byte inputCount =...
Can somebody help me with the Use Case Diagram . I am confused of what I am suppose to do. Here are the instructions : Your team should produce a Use Case Diagram and the associated Use Case Descriptions/Narratives for all the use cases in the diagram. The resulting document should havethe “professional look” and produced by a word processor, graphics/presentation/drawing software, and/or a CASE tool (e.g., Microsoft Word, Microsoft PowerPoint, ArgoUML, Dia, Visual Paradigm, Visio, etc.). All project documentation...