Skip to content

Commit

Permalink
comments
Browse files Browse the repository at this point in the history
  • Loading branch information
mayraazamora committed Mar 22, 2023
1 parent 0f0cb68 commit aca038c
Show file tree
Hide file tree
Showing 4 changed files with 72 additions and 164 deletions.
174 changes: 48 additions & 126 deletions Assets/Scenes/FoodFight.unity
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,50 @@ NavMeshSettings:
debug:
m_Flags: 0
m_NavMeshData: {fileID: 0}
--- !u!1 &415148589
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 415148590}
- component: {fileID: 415148591}
m_Layer: 0
m_Name: Game
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &415148590
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 415148589}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &415148591
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 415148589}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: cb8a889718b702347aa4c5f4a9d2587a, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!1001 &445926611
PrefabInstance:
m_ObjectHideFlags: 0
Expand Down Expand Up @@ -433,7 +477,7 @@ Transform:
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 0
m_RootOrder: 1
m_LocalEulerAnglesHint: {x: 50, y: -30, z: 0}
--- !u!1 &928839163
GameObject:
Expand All @@ -459,7 +503,7 @@ Transform:
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 928839163}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalPosition: {x: 0, y: 1.36144, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children:
Expand Down Expand Up @@ -668,7 +712,7 @@ Transform:
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 2
m_RootOrder: 3
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &1518760941
GameObject:
Expand Down Expand Up @@ -718,7 +762,7 @@ Transform:
m_Children:
- {fileID: 928839164}
m_Father: {fileID: 0}
m_RootOrder: 1
m_RootOrder: 2
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1001 &3786808346532864512
PrefabInstance:
Expand Down Expand Up @@ -781,125 +825,3 @@ PrefabInstance:
objectReference: {fileID: 0}
m_RemovedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: 3b4c3b9543050b84cb38e2ff36f570f6, type: 3}
--- !u!1001 &7232580169891898871
PrefabInstance:
m_ObjectHideFlags: 0
serializedVersion: 2
m_Modification:
m_TransformParent: {fileID: 0}
m_Modifications:
- target: {fileID: 1518816339359218834, guid: d4be3d13d9c83fc4babd5b4f07326bc7, type: 3}
propertyPath: m_Name
value: HoopCircle
objectReference: {fileID: 0}
- target: {fileID: 6346585861985980303, guid: d4be3d13d9c83fc4babd5b4f07326bc7, type: 3}
propertyPath: m_Constraints
value: 126
objectReference: {fileID: 0}
- target: {fileID: 6346585861985980303, guid: d4be3d13d9c83fc4babd5b4f07326bc7, type: 3}
propertyPath: m_CollisionDetection
value: 0
objectReference: {fileID: 0}
- target: {fileID: 7756821538548920233, guid: d4be3d13d9c83fc4babd5b4f07326bc7, type: 3}
propertyPath: m_RootOrder
value: 3
objectReference: {fileID: 0}
- target: {fileID: 7756821538548920233, guid: d4be3d13d9c83fc4babd5b4f07326bc7, type: 3}
propertyPath: m_LocalScale.x
value: 0.47961354
objectReference: {fileID: 0}
- target: {fileID: 7756821538548920233, guid: d4be3d13d9c83fc4babd5b4f07326bc7, type: 3}
propertyPath: m_LocalScale.y
value: 0.47961354
objectReference: {fileID: 0}
- target: {fileID: 7756821538548920233, guid: d4be3d13d9c83fc4babd5b4f07326bc7, type: 3}
propertyPath: m_LocalScale.z
value: 0.47961354
objectReference: {fileID: 0}
- target: {fileID: 7756821538548920233, guid: d4be3d13d9c83fc4babd5b4f07326bc7, type: 3}
propertyPath: m_LocalPosition.x
value: 1.5051
objectReference: {fileID: 0}
- target: {fileID: 7756821538548920233, guid: d4be3d13d9c83fc4babd5b4f07326bc7, type: 3}
propertyPath: m_LocalPosition.y
value: 2.5771
objectReference: {fileID: 0}
- target: {fileID: 7756821538548920233, guid: d4be3d13d9c83fc4babd5b4f07326bc7, type: 3}
propertyPath: m_LocalPosition.z
value: 1.0317
objectReference: {fileID: 0}
- target: {fileID: 7756821538548920233, guid: d4be3d13d9c83fc4babd5b4f07326bc7, type: 3}
propertyPath: m_LocalRotation.w
value: 0.70602477
objectReference: {fileID: 0}
- target: {fileID: 7756821538548920233, guid: d4be3d13d9c83fc4babd5b4f07326bc7, type: 3}
propertyPath: m_LocalRotation.x
value: 0.70602477
objectReference: {fileID: 0}
- target: {fileID: 7756821538548920233, guid: d4be3d13d9c83fc4babd5b4f07326bc7, type: 3}
propertyPath: m_LocalRotation.y
value: -0.039103046
objectReference: {fileID: 0}
- target: {fileID: 7756821538548920233, guid: d4be3d13d9c83fc4babd5b4f07326bc7, type: 3}
propertyPath: m_LocalRotation.z
value: 0.039103046
objectReference: {fileID: 0}
- target: {fileID: 7756821538548920233, guid: d4be3d13d9c83fc4babd5b4f07326bc7, type: 3}
propertyPath: m_LocalEulerAnglesHint.x
value: 90
objectReference: {fileID: 0}
- target: {fileID: 7756821538548920233, guid: d4be3d13d9c83fc4babd5b4f07326bc7, type: 3}
propertyPath: m_LocalEulerAnglesHint.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 7756821538548920233, guid: d4be3d13d9c83fc4babd5b4f07326bc7, type: 3}
propertyPath: m_LocalEulerAnglesHint.z
value: 6.34
objectReference: {fileID: 0}
- target: {fileID: 8239143562408604279, guid: d4be3d13d9c83fc4babd5b4f07326bc7, type: 3}
propertyPath: m_Materials.Array.data[0]
value:
objectReference: {fileID: 2100000, guid: 9250b9ad78a2b54469538d1c2d272aca, type: 2}
m_RemovedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: d4be3d13d9c83fc4babd5b4f07326bc7, type: 3}
--- !u!1 &8164078559499934053 stripped
GameObject:
m_CorrespondingSourceObject: {fileID: 1518816339359218834, guid: d4be3d13d9c83fc4babd5b4f07326bc7, type: 3}
m_PrefabInstance: {fileID: 7232580169891898871}
m_PrefabAsset: {fileID: 0}
--- !u!895512359 &8164078559499934056
AimConstraint:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 8164078559499934053}
m_Enabled: 1
m_Weight: 1
m_RotationAtRest: {x: 90, y: 0, z: 0}
m_RotationOffset: {x: 0, y: 0, z: 0}
m_AimVector: {x: 0, y: 0, z: 1}
m_UpVector: {x: 0, y: 1, z: 0}
m_WorldUpVector: {x: 0, y: 1, z: 0}
m_WorldUpObject: {fileID: 0}
m_UpType: 0
m_AffectRotationX: 1
m_AffectRotationY: 1
m_AffectRotationZ: 1
m_IsContraintActive: 0
m_IsLocked: 0
m_Sources: []
--- !u!114 &8164078559499934062
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 8164078559499934053}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 3e3768de982a9f6419ccb7523a9f32e4, type: 3}
m_Name:
m_EditorClassIdentifier:
range: 0.5
speed: 2
12 changes: 4 additions & 8 deletions Assets/Scripts/FoodFight.cs
Original file line number Diff line number Diff line change
@@ -1,18 +1,14 @@
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class FoodFight : MonoBehaviour
{
// Start is called before the first frame update
void Start()
{

}
private int score;

// Update is called once per frame
void Update()
public void OnTargetHit()
{

score += 1;
}
}
38 changes: 11 additions & 27 deletions Assets/Scripts/ObjectThrower.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,37 +12,21 @@ public class ObjectThrower : MonoBehaviour
private Rigidbody heldObject; // Food that is chosen at random, cloned, and then spawned

void Update()
{
// Check if the hands trigger button has been pressed
if (Input.GetButtonDown(triggerName))
{
if (Input.GetButtonDown(triggerName)) // Check if the hands trigger button has been pressed
{
// Choose a food prefab at random to spawn
Rigidbody randomObject = objects[Random.Range(0, objects.Length)];

// Spawn the randomly selected food in hand
heldObject = Instantiate(randomObject, transform.position, transform.rotation, transform);

// Turn off gravity so that food does not fall from your hand as it spawns
heldObject.useGravity = false;

// Avoid having external objects interfere with our food while we are holding it
heldObject.isKinematic = true;
Rigidbody randomObject = objects[Random.Range(0, objects.Length)]; // Choose a food prefab at random to spawn
heldObject = Instantiate(randomObject, transform.position, transform.rotation, transform); // Spawn the randomly selected food in hand
heldObject.useGravity = false; // Turn off gravity so that food does not fall from your hand as it spawns
heldObject.isKinematic = true; // Avoid having external objects interfere with our food while we are holding it
}

// Check if the hands trigger button has been released
if (Input.GetButtonUp(triggerName))
if (Input.GetButtonUp(triggerName)) // Check if the hands trigger button has been released
{
// Unparent food from the hand; otherwise, it will follow the hand even on the ground.
heldObject.transform.SetParent(null);

// Restore gravity; otherwise, food will float in space.
heldObject.useGravity = true;

// We want our food to interact "normally" with external forces of objects.
heldObject.isKinematic = false;

// Apply a force to the food object to throw it
heldObject.AddForce(transform.forward * throwImpulse);
heldObject.transform.SetParent(null); // Unparent food from the hand; otherwise, it will follow the hand even on the ground.
heldObject.useGravity = true; // Restore gravity; otherwise, food will float in space.
heldObject.isKinematic = false; // We want our food to interact "normally" with external forces of objects.
heldObject.AddForce(transform.forward * throwImpulse); // Apply a force to the food object to throw it

}
}
Expand Down
12 changes: 9 additions & 3 deletions Assets/Scripts/Target.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,14 @@
public class Target : MonoBehaviour
{
public float range;
public float speed;
public float speed;
public FoodFight game; // Game manager script we are connecting

private Vector3 initialPosition; // The initial position of the target

private void Start()
{
initialPosition = transform.position;
initialPosition = transform.position; // Takes into account the position of the target so target does not start at (0,0,0)
}

void Update()
Expand All @@ -19,8 +21,12 @@ void Update()

private void OnCollisionEnter(Collision collision)
{
mayra.hit();
game.OnTargetHit(); // Let the game know the target was hit
Destroy(gameObject); // Destroys target bullsye
Destroy(collision.collider.gameObject); // Destroys food prefabs when colliding with target
Debug.Log($"target has been hit {collision.collider.gameObject.name}"); // Logs name of food that touches target
}
}

// Logs name of food that touches target
// Debug.Log($"target has been hit {collision.collider.gameObject.name}");

0 comments on commit aca038c

Please sign in to comment.