Slime Temp and Bug fixes

>Fixed some bakes with the Hail
>Fixed the movement bugs with the king's movement
>Added the Slime in a semi-functional state
This commit is contained in:
Katherine
2022-02-10 15:54:16 -06:00
parent 3c1e36726a
commit 35c5c41f5a
7 changed files with 136 additions and 52 deletions

View File

@@ -29,7 +29,7 @@ Transform:
m_GameObject: {fileID: 9109488354154531999}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: -29.02, y: 0.165, z: -21.09}
m_LocalScale: {x: 0.083767, y: 1, z: 0.1153}
m_LocalScale: {x: 2, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 0

View File

@@ -9474,6 +9474,7 @@ GameObject:
- component: {fileID: 343653236}
- component: {fileID: 343653235}
- component: {fileID: 343653234}
- component: {fileID: 343653237}
- component: {fileID: 343653233}
m_Layer: 0
m_Name: TestSlime
@@ -9482,20 +9483,19 @@ GameObject:
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!136 &343653233
CapsuleCollider:
--- !u!65 &343653233
BoxCollider:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 343653232}
m_Material: {fileID: 0}
m_IsTrigger: 1
m_IsTrigger: 0
m_Enabled: 1
m_Radius: 0.5
m_Height: 1
m_Direction: 1
m_Center: {x: 0, y: 0.021134948, z: 0}
serializedVersion: 2
m_Size: {x: 0.12903199, y: 0.12903199, z: 0.12903199}
m_Center: {x: 0, y: 0.06451599, z: 0}
--- !u!23 &343653234
MeshRenderer:
m_ObjectHideFlags: 0
@@ -9544,7 +9544,7 @@ MeshFilter:
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 343653232}
m_Mesh: {fileID: 10207, guid: 0000000000000000e000000000000000, type: 0}
m_Mesh: {fileID: 1360138328677090702, guid: d583fb6b27d23a849b80c1ea7d813943, type: 3}
--- !u!4 &343653236
Transform:
m_ObjectHideFlags: 0
@@ -9554,11 +9554,28 @@ Transform:
m_GameObject: {fileID: 343653232}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 486.3, y: 501.02, z: 1306.41}
m_LocalScale: {x: 20, y: 20, z: 20}
m_LocalScale: {x: 150, y: 150, z: 150}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 17
m_RootOrder: 18
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &343653237
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 343653232}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 16272419deebd26418bee88aca87e679, type: 3}
m_Name:
m_EditorClassIdentifier:
Goo: {fileID: 9109488354154531999, guid: e0a933a7f4d98134ea0c045fabc6a6a0, type: 3}
Folder: {fileID: 497375465}
LayerMask:
serializedVersion: 2
m_Bits: 64
--- !u!1 &343654569
GameObject:
m_ObjectHideFlags: 0
@@ -12952,6 +12969,36 @@ MeshFilter:
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 496382787}
m_Mesh: {fileID: 10202, guid: 0000000000000000e000000000000000, type: 0}
--- !u!1 &497375465
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 497375466}
m_Layer: 0
m_Name: GooHolder
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &497375466
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 497375465}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 164.64146, y: 118.0139, z: 620.85126}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 19
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &499423962
GameObject:
m_ObjectHideFlags: 0
@@ -57753,7 +57800,7 @@ PrefabInstance:
objectReference: {fileID: 0}
- target: {fileID: 2793902819963175727, guid: c642a15af2183e94f81d67ead9ec7326, type: 3}
propertyPath: m_RootOrder
value: 18
value: 17
objectReference: {fileID: 0}
- target: {fileID: 2793902819963175727, guid: c642a15af2183e94f81d67ead9ec7326, type: 3}
propertyPath: m_LocalPosition.x
@@ -61562,6 +61609,10 @@ PrefabInstance:
m_Modification:
m_TransformParent: {fileID: 0}
m_Modifications:
- target: {fileID: 4195644339311798069, guid: d23bf55f2a40d494487eb188930f895d, type: 3}
propertyPath: Slime
value:
objectReference: {fileID: 343653232}
- target: {fileID: 4195644339311798069, guid: d23bf55f2a40d494487eb188930f895d, type: 3}
propertyPath: HailObject
value:

View File

@@ -8,16 +8,18 @@ public class Goo : MonoBehaviour
void FixedUpdate() {
Lifetime++;
if(Lifetime == 550) {
if(Lifetime == 950) {
Destruction();
}
}
//Makes the player sliperly whenever they step on the goo
void OnTriggerEnter(Collider other) {
Debug.Log("Slippy!");
GameObject player = other.gameObject;//Turns the collider into a game object
player.GetComponent<PlayerStats>().Traction = 1.5f;//Make it slippy
if (other.tag == "Player") {
Debug.Log("Slippy!");
GameObject player = other.gameObject;//Turns the collider into a game object
player.GetComponent<PlayerStats>().Traction = 1.5f;//Make it slippy
}
}
void Destruction() {

View File

@@ -16,6 +16,7 @@ public class HailArea : MonoBehaviour
int timer = 0;
RaycastHit hit;
[SerializeField] private LayerMask LayerMask;
float height = 0f;
// FixedUpdate is called once per .02 seconds (or 50 times a second)
void FixedUpdate()
@@ -29,8 +30,7 @@ public class HailArea : MonoBehaviour
//Random pos Z Zmax-radius -> Zmin+radius
Vector3 position = new Vector3(Random.Range(Xmin + radius, Xmax - radius), 100, Random.Range(Zmin + radius, Zmax - radius));//Finds where the hail will spawn in the air
if (Physics.Raycast(position, transform.TransformDirection(Vector3.down), out hit, float.MaxValue)) {//Raycasts to find where the ground is
Debug.DrawRay(position, transform.TransformDirection(Vector3.down) * 100, Color.yellow);
if (Physics.Raycast(position, transform.TransformDirection(Vector3.down), out hit, float.MaxValue, LayerMask)) {//Raycasts to find where the ground is
height = 100 - hit.distance;
}
position = new Vector3(position.x, 100+height, position.z); //find ground and set y occordingly

View File

@@ -46,11 +46,13 @@ public class KingMove : MonoBehaviour
else if (transform.position.x < -4500) {//Once they rech a certain point they begin to cirlce around the mountain (radius of 1050, (x+4500)^2+(z-510)^2=620^2)
float z = transform.position.z;
z -= translation; //Moves the player's X forward slightly
float x = -Mathf.Sqrt((620 * 620) - ((z-510) * (z-510))) - 4500; //Snaps the player onto a circle that is around the mountain, so the player orbits it smoothly
newPos = new Vector3(x, 620, z); //make a Vector3 out of the new X and Z
transform.position = newPos;//Sets the player's new position on the cirlce
transform.LookAt(MountCent);//Rotates the player as they move along the circumfurance
if (z > 1130) {//Snaps the player back onto the horizontal track
if (z >= -110) { //Stops this from breaking the circle's formula
float x = -Mathf.Sqrt((620 * 620) - ((z - 510) * (z - 510))) - 4500; //Snaps the player onto a circle that is around the mountain, so the player orbits it smoothly
newPos = new Vector3(x, 620, z); //make a Vector3 out of the new X and Z
transform.position = newPos;//Sets the player's new position on the cirlce
transform.LookAt(MountCent);//Rotates the player as they move along the circumfurance
}
else if (z > 1130) {//Snaps the player back onto the horizontal track
transform.position = new Vector3(-4500, 625, 1130);
}
}

View File

@@ -39,7 +39,7 @@ public class KingPlace : NetworkBehaviour
private GameObject Place;
private GameObject PlaceTemp;
private GameObject HailCorner;
private GameObject SlimeDir;
private int SlimeDir;
private bool FirstPlacing = false;
private bool HailPlacing = false;
private bool SlimePlacing = false;
@@ -93,13 +93,16 @@ public class KingPlace : NetworkBehaviour
{
HailCorner.transform.position = RayCastHit.point;
}
if (Input.GetMouseButtonUp(0)) {//Reads the player clicking the left mouse button again
if (Input.GetMouseButtonUp(0)) {//Reads the player releasing the left mouse button
CreateHail();
}
}
if (SlimePlacing == true) {
//TODO draw arrow in direction of slime move
//TODO CreateSlime function?
SlimeDir = DrawArrow();
if (Input.GetMouseButtonUp(0)) {//Reads the player releasing the left mouse button
PlaceTemp.GetComponent<Slime>().GooStart(SlimeDir);
SlimePlacing = false;
}
}
}
@@ -172,6 +175,11 @@ public class KingPlace : NetworkBehaviour
}
}
private int DrawArrow() {
//TODO convert mouse position to arrow direction. then return the int of what direction it is
return 2;
}
[ServerRpc(RequireOwnership = false)]
private void SpawnBoxServerRPC(Vector3 spawnLoc) {
boxPlaced = Instantiate(Block, spawnLoc, Quaternion.identity);

View File

@@ -4,46 +4,67 @@ using UnityEngine;
public class Slime : MonoBehaviour
{
float MoveDir;
float MoveSpd;
int GooTimer = 0;
Vector3 offset = new Vector3(0.0f, 0.4f, 0.0f);
bool GooGo = false;
Vector3 offset = new Vector3(0.0f, -0.1f, 0.0f);
Vector3 MoveDir = new Vector3(0, 0, 1);
RaycastHit hit;
public GameObject Goo;
public GameObject Folder;
public int StartPos = -29;
public int EndPos = -57;
[SerializeField] private LayerMask LayerMask;
// Start is called before the first frame update
void Start()
{
MoveDir = Time.deltaTime;
MoveSpd = 9*Time.deltaTime;
}
// FixedUpdate is called once per .02 seconds (or 50 times a second)
void FixedUpdate()
{
//create goo underneath them slime
if (GooTimer == 6) {
GameObject GooTrail = null;
GooTrail = Instantiate(Goo, transform.position - offset, transform.rotation);
GooTrail.transform.parent = Folder.transform;
GooTimer = 0;
if (GooGo == true) {//Makes it make goo and move only if it's already placed
//create goo underneath them slime
if (GooTimer == 6) {
GameObject GooTrail = null;
GooTrail = Instantiate(Goo, transform.position - offset, transform.rotation);
GooTrail.transform.parent = Folder.transform;
GooTimer = 0;
}
//attempt to move forward(Raycast infront for objects, and also raycast down, to make sure there's still ground underneath it)
if (Physics.Raycast(transform.position, transform.TransformDirection(MoveDir), out hit, 1.5f, LayerMask) || Physics.Raycast(transform.position, transform.TransformDirection(Vector3.down), out hit, 50f, LayerMask)) {//turns it around when it hits something or is going to go over a pit//TODO hit more than terrain
MoveDir = -MoveDir;
}
transform.Translate(MoveSpd*MoveDir);//moving forward
GooTimer++;
}
//attempt to move forward(Raycast for objects, how to make sure it didn't fall off a cliff?)
if (transform.position.z >= StartPos || transform.position.z <= EndPos) {//Rough way of keeping turning it around when it reaches an end
MoveDir = -MoveDir;
}
//if can't Turn around 180 degrees
//otherwise actually move forward
transform.Translate(0, 0, MoveDir);
GooTimer++;
}
void OnTriggerStay(Collider other) {
//slow down player
GameObject player = other.gameObject;//Turns the collider into a game object
//Get the Player's speed
float CurVel = player.GetComponent<PlayerStats>().CurVel;
player.GetComponent<PlayerStats>().CurVel = CurVel - (CurVel/10);
//Cut it in half?
if (other.tag == "Player") {
//slow down player
GameObject player = other.gameObject;//Turns the collider into a game object
float CurVel = player.GetComponent<PlayerStats>().CurVel;//Get the Player's speed
player.GetComponent<PlayerStats>().CurVel = CurVel - (CurVel / 10);
//Cut it in half?
}
}
public void GooStart(int SlimeDir) {
GooGo = true;
switch (SlimeDir) {//Sets the slime's initial direction properly
case 0:
MoveDir = Vector3.back;
break;
case 1:
MoveDir = Vector3.left;
break;
case 2:
MoveDir = Vector3.forward;
break;
case 3:
MoveDir = Vector3.right;
break;
}
}
}