Boost basics done, need to smooth things
This commit is contained in:
parent
437f295dd7
commit
1cd3453199
|
|
@ -1,7 +1,6 @@
|
|||
/Library/**
|
||||
/Temp/**
|
||||
/Temp/
|
||||
/ProjectSettings/ProjectVersion.txt
|
||||
/Library/*
|
||||
/Temp/*
|
||||
/Temp
|
||||
**.log
|
||||
**.sln
|
||||
**.csproj
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ RenderSettings:
|
|||
m_ReflectionIntensity: 1
|
||||
m_CustomReflection: {fileID: 0}
|
||||
m_Sun: {fileID: 0}
|
||||
m_IndirectSpecularColor: {r: 0.44657898, g: 0.4964133, b: 0.5748178, a: 1}
|
||||
m_IndirectSpecularColor: {r: 0.44657874, g: 0.49641258, b: 0.5748172, a: 1}
|
||||
m_UseRadianceAmbientProbe: 0
|
||||
--- !u!157 &3
|
||||
LightmapSettings:
|
||||
|
|
@ -579,6 +579,7 @@ MonoBehaviour:
|
|||
m_EditorClassIdentifier:
|
||||
trailCollidersParent: {fileID: 697893403}
|
||||
deadScreen: {fileID: 508845190}
|
||||
boostBtn: {fileID: 2133876932}
|
||||
--- !u!4 &332697609
|
||||
Transform:
|
||||
m_ObjectHideFlags: 0
|
||||
|
|
@ -2316,6 +2317,81 @@ Transform:
|
|||
m_Father: {fileID: 0}
|
||||
m_RootOrder: 3
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!1 &1294043775
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 1294043776}
|
||||
- component: {fileID: 1294043778}
|
||||
- component: {fileID: 1294043777}
|
||||
m_Layer: 5
|
||||
m_Name: boost
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!224 &1294043776
|
||||
RectTransform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1294043775}
|
||||
m_LocalRotation: {x: 0, y: 0, z: -0.3289491, w: 0.9443477}
|
||||
m_LocalPosition: {x: 0, y: 0, z: 0}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_Children: []
|
||||
m_Father: {fileID: 2133876931}
|
||||
m_RootOrder: 0
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: -38.41}
|
||||
m_AnchorMin: {x: 0.5, y: 0.5}
|
||||
m_AnchorMax: {x: 0.5, y: 0.5}
|
||||
m_AnchoredPosition: {x: 0, y: 0}
|
||||
m_SizeDelta: {x: 100, y: 100}
|
||||
m_Pivot: {x: 0.5, y: 0.5}
|
||||
--- !u!114 &1294043777
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1294043775}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
m_Material: {fileID: 0}
|
||||
m_Color: {r: 1, g: 0.38597703, b: 0, a: 1}
|
||||
m_RaycastTarget: 1
|
||||
m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
|
||||
m_Maskable: 1
|
||||
m_OnCullStateChanged:
|
||||
m_PersistentCalls:
|
||||
m_Calls: []
|
||||
m_Sprite: {fileID: 21300000, guid: b5b8d7f1b3094453c984e82dd580bf76, type: 3}
|
||||
m_Type: 0
|
||||
m_PreserveAspect: 0
|
||||
m_FillCenter: 1
|
||||
m_FillMethod: 4
|
||||
m_FillAmount: 1
|
||||
m_FillClockwise: 1
|
||||
m_FillOrigin: 0
|
||||
m_UseSpriteMesh: 0
|
||||
m_PixelsPerUnitMultiplier: 1
|
||||
--- !u!222 &1294043778
|
||||
CanvasRenderer:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1294043775}
|
||||
m_CullTransparentMesh: 1
|
||||
--- !u!1 &1351776592
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
|
|
@ -2864,6 +2940,7 @@ RectTransform:
|
|||
- {fileID: 474562392}
|
||||
- {fileID: 508845191}
|
||||
- {fileID: 1083193387}
|
||||
- {fileID: 2133876931}
|
||||
m_Father: {fileID: 0}
|
||||
m_RootOrder: 1
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
|
|
@ -2872,6 +2949,128 @@ RectTransform:
|
|||
m_AnchoredPosition: {x: 0, y: 0}
|
||||
m_SizeDelta: {x: 0, y: 0}
|
||||
m_Pivot: {x: 0, y: 0}
|
||||
--- !u!1 &2133876930
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 2133876931}
|
||||
- component: {fileID: 2133876934}
|
||||
- component: {fileID: 2133876933}
|
||||
- component: {fileID: 2133876932}
|
||||
m_Layer: 5
|
||||
m_Name: btn_boost
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!224 &2133876931
|
||||
RectTransform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 2133876930}
|
||||
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_Children:
|
||||
- {fileID: 1294043776}
|
||||
m_Father: {fileID: 2058016609}
|
||||
m_RootOrder: 3
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
m_AnchorMin: {x: 1, y: 0}
|
||||
m_AnchorMax: {x: 1, y: 0}
|
||||
m_AnchoredPosition: {x: -100, y: 100}
|
||||
m_SizeDelta: {x: 100, y: 100}
|
||||
m_Pivot: {x: 0.5, y: 0.5}
|
||||
--- !u!114 &2133876932
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 2133876930}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: d0b148fe25e99eb48b9724523833bab1, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
m_Delegates:
|
||||
- eventID: 2
|
||||
callback:
|
||||
m_PersistentCalls:
|
||||
m_Calls:
|
||||
- m_Target: {fileID: 332697608}
|
||||
m_TargetAssemblyTypeName: SceneDataHolder, Assembly-CSharp
|
||||
m_MethodName: OnBoostDown
|
||||
m_Mode: 1
|
||||
m_Arguments:
|
||||
m_ObjectArgument: {fileID: 0}
|
||||
m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine
|
||||
m_IntArgument: 0
|
||||
m_FloatArgument: 0
|
||||
m_StringArgument:
|
||||
m_BoolArgument: 0
|
||||
m_CallState: 2
|
||||
- eventID: 3
|
||||
callback:
|
||||
m_PersistentCalls:
|
||||
m_Calls:
|
||||
- m_Target: {fileID: 332697608}
|
||||
m_TargetAssemblyTypeName: SceneDataHolder, Assembly-CSharp
|
||||
m_MethodName: OnBoostUp
|
||||
m_Mode: 1
|
||||
m_Arguments:
|
||||
m_ObjectArgument: {fileID: 0}
|
||||
m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine
|
||||
m_IntArgument: 0
|
||||
m_FloatArgument: 0
|
||||
m_StringArgument:
|
||||
m_BoolArgument: 0
|
||||
m_CallState: 2
|
||||
--- !u!114 &2133876933
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 2133876930}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
m_Material: {fileID: 0}
|
||||
m_Color: {r: 1, g: 1, b: 1, a: 1}
|
||||
m_RaycastTarget: 1
|
||||
m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
|
||||
m_Maskable: 1
|
||||
m_OnCullStateChanged:
|
||||
m_PersistentCalls:
|
||||
m_Calls: []
|
||||
m_Sprite: {fileID: 21300000, guid: bae2699007f4e40bfb782060cfeecd25, type: 3}
|
||||
m_Type: 0
|
||||
m_PreserveAspect: 0
|
||||
m_FillCenter: 1
|
||||
m_FillMethod: 4
|
||||
m_FillAmount: 1
|
||||
m_FillClockwise: 1
|
||||
m_FillOrigin: 0
|
||||
m_UseSpriteMesh: 0
|
||||
m_PixelsPerUnitMultiplier: 1
|
||||
--- !u!222 &2133876934
|
||||
CanvasRenderer:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 2133876930}
|
||||
m_CullTransparentMesh: 1
|
||||
--- !u!1 &2145051019
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
|
|
|
|||
|
|
@ -7,6 +7,8 @@ public class CameraFollower : MonoBehaviour
|
|||
public bool autoOffset = true;
|
||||
public Vector3 offset;
|
||||
public Transform target;
|
||||
public float minFOV = 11;
|
||||
public float FOVmultiplier = 5;
|
||||
public float smoothness = 0.1f;
|
||||
void Start()
|
||||
{
|
||||
|
|
@ -19,6 +21,7 @@ public class CameraFollower : MonoBehaviour
|
|||
{
|
||||
if(target==null){return;}
|
||||
transform.position = Vector3.Lerp(transform.position, target.position + offset, smoothness * Time.deltaTime);
|
||||
GetComponent<Camera>().orthographicSize = minFOV + ((target.localScale.x - 1) * FOVmultiplier);
|
||||
}
|
||||
|
||||
public void SetTarget(Transform Target){
|
||||
|
|
|
|||
|
|
@ -1,19 +1,31 @@
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Events;
|
||||
using UnityEngine.EventSystems;
|
||||
|
||||
public class SceneDataHolder : MonoBehaviour
|
||||
{
|
||||
public Transform trailCollidersParent;
|
||||
public GameObject deadScreen;
|
||||
public EventTrigger boostBtn;
|
||||
void Awake()
|
||||
{
|
||||
SceneData.holder = this;
|
||||
}
|
||||
|
||||
public void OnBoostUp(){
|
||||
SceneData.OnBoostUp.Invoke();
|
||||
}
|
||||
public void OnBoostDown(){
|
||||
SceneData.OnBoostDown.Invoke();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static class SceneData{
|
||||
public static GameObject localPlayer;
|
||||
public static SceneDataHolder holder;
|
||||
public static UnityEvent OnBoostDown = new UnityEvent();
|
||||
public static UnityEvent OnBoostUp = new UnityEvent();
|
||||
}
|
||||
|
|
@ -15,6 +15,10 @@ public class SpaceshipController : NetworkBehaviour
|
|||
public float trailIncrementRate = 0.5f;
|
||||
[SyncVar]
|
||||
public bool dead;
|
||||
[SyncVar]
|
||||
public float speed;
|
||||
[SyncVar(hook=nameof(OnScaleChanged))]
|
||||
public float scaleMultiplier=1;
|
||||
public Text pnameTxt;
|
||||
public Transform body;
|
||||
public TrailMgr trailMgr;
|
||||
|
|
@ -22,6 +26,8 @@ public class SpaceshipController : NetworkBehaviour
|
|||
public float turningSmoothFactor = 0.1f;
|
||||
public Joystick joystick;
|
||||
public Vector2 joyInput;
|
||||
[SyncVar]
|
||||
public bool boosting;
|
||||
|
||||
[Header("Client Prediction")]
|
||||
public SortedDictionary<int, StatePayload> serverStateBuffer = new SortedDictionary<int, StatePayload>();
|
||||
|
|
@ -49,14 +55,51 @@ public class SpaceshipController : NetworkBehaviour
|
|||
trailMgr.trail.time = newValue;
|
||||
}
|
||||
|
||||
void OnBoostDown(){
|
||||
if(isLocalPlayer){
|
||||
if(isServer){
|
||||
boosting=true;
|
||||
}else{
|
||||
CmdSetBoosting(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void OnBoostUp(){
|
||||
if(isLocalPlayer){
|
||||
if(isServer){
|
||||
boosting=false;
|
||||
}else{
|
||||
CmdSetBoosting(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void OnScaleChanged(float oldScale, float newScale){
|
||||
transform.localScale = new Vector3(newScale,newScale,newScale);
|
||||
trailMgr.trail.startWidth = trailMgr.trail.endWidth = newScale;
|
||||
|
||||
if(isLocalPlayer){
|
||||
SceneData.holder.boostBtn.gameObject.SetActive(newScale>1);
|
||||
}
|
||||
}
|
||||
|
||||
[Command]
|
||||
void CmdSetBoosting(bool value){
|
||||
boosting=value;
|
||||
}
|
||||
|
||||
void Start()
|
||||
{
|
||||
scaleMultiplier=1;
|
||||
if (isLocalPlayer)
|
||||
{
|
||||
if (joystick == null) { joystick = FindObjectOfType<Joystick>(); }
|
||||
FindObjectOfType<CameraFollower>().SetTarget(transform);
|
||||
string myName = PlayerPrefs.GetString("username");
|
||||
SceneData.localPlayer = gameObject;
|
||||
SceneData.OnBoostDown.AddListener(OnBoostDown);
|
||||
SceneData.OnBoostUp.AddListener(OnBoostUp);
|
||||
if(isServer){pname=myName;}else{
|
||||
CmdSetPname(myName);
|
||||
}
|
||||
|
|
@ -84,16 +127,33 @@ public class SpaceshipController : NetworkBehaviour
|
|||
if (isLocalPlayer)
|
||||
{
|
||||
joyInput = joystick.input;
|
||||
|
||||
//Cheats => TODO: Remove this
|
||||
if(Input.GetKeyDown(KeyCode.F)){
|
||||
CmdCheatKills();
|
||||
}
|
||||
}
|
||||
//Simulate on both client and server
|
||||
if (isLocalPlayer || isServer)
|
||||
{
|
||||
body.Translate(new Vector3(0, movingSpeed), body);
|
||||
body.Translate(new Vector3(0, speed), body);
|
||||
if (joyInput != Vector2.zero)
|
||||
{
|
||||
Turn(joyInput);
|
||||
}
|
||||
}
|
||||
|
||||
if(isServer){
|
||||
//boost check
|
||||
if(boosting && scaleMultiplier > 1){
|
||||
speed= movingSpeed*2;
|
||||
scaleMultiplier-=Time.deltaTime;
|
||||
|
||||
if(scaleMultiplier<1){scaleMultiplier=1;} //Clamp in case gets lower
|
||||
}else{
|
||||
speed=movingSpeed;
|
||||
}
|
||||
}
|
||||
///Diff = rot1 . rot2
|
||||
///1 = rot1 . rot2 / Diff
|
||||
///1 * Diff * Diff = rot1.rot2. Diff
|
||||
|
|
@ -162,7 +222,7 @@ public class SpaceshipController : NetworkBehaviour
|
|||
Quaternion newRotation = rotation;
|
||||
for (int i = 0; i < numberOfFrames; i++)
|
||||
{
|
||||
newPosition += new Vector3(0, movingSpeed);
|
||||
newPosition += new Vector3(0, speed);
|
||||
newRotation = Quaternion.Lerp(newRotation, getTurnAngle(input), turningSmoothFactor * input.magnitude);
|
||||
}
|
||||
|
||||
|
|
@ -251,7 +311,7 @@ public class SpaceshipController : NetworkBehaviour
|
|||
Quaternion newRotation = rotation;
|
||||
for (int i = 0; i < numberOfFrames; i++)
|
||||
{
|
||||
newPosition += new Vector3(0, movingSpeed);
|
||||
newPosition += new Vector3(0, speed);
|
||||
newRotation = Quaternion.Lerp(newRotation, getTurnAngle(input), turningSmoothFactor * input.magnitude);
|
||||
}
|
||||
int distanceSinceSent = (int)Vector3.Distance(newPosition, position);
|
||||
|
|
@ -333,20 +393,34 @@ public class SpaceshipController : NetworkBehaviour
|
|||
}
|
||||
|
||||
SpaceshipController deadPlayer = hit.collider.GetComponent<SpaceshipController>();
|
||||
if(deadPlayer!=null && !deadPlayer.dead){ // <-- okay we killed someone
|
||||
|
||||
if(deadPlayer!=null && !deadPlayer.dead){ // <-- okay we killed someone | KILLCODE
|
||||
deadPlayer.Die(pname);
|
||||
Debug.Log($"{pname} killed {deadPlayer.pname}");
|
||||
|
||||
Scores+= 10; //TODO: Need to change Scores on kills?
|
||||
trailTime = trailMgr.trail.time+ trailIncrementRate;
|
||||
trailMgr.trail.time = trailTime;
|
||||
OnKill();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
void OnKill(){
|
||||
Scores+= 10; //TODO: Need to change Scores on kills?
|
||||
scaleMultiplier+=0.05f;
|
||||
OnScaleChanged(scaleMultiplier,scaleMultiplier);
|
||||
trailTime = trailMgr.trail.time+ trailIncrementRate;
|
||||
trailMgr.trail.time = trailTime;
|
||||
}
|
||||
|
||||
[Command]
|
||||
void CmdCheatKills(){
|
||||
OnKill();
|
||||
}
|
||||
|
||||
public void Die(string killer){
|
||||
Debug.Log($"Sending death signal to {pname} by {killer}");
|
||||
|
||||
//Handle Respawning
|
||||
OnScaleChanged(scaleMultiplier,1);
|
||||
scaleMultiplier=1;
|
||||
dead=true;
|
||||
trailTime = 1;
|
||||
trailMgr.trail.time = trailTime;
|
||||
|
|
|
|||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user