Skip to content

Fix: Refactor of click target feedback #569

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Mar 17, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
72 changes: 72 additions & 0 deletions Assets/BossRoom/Models/ClickFeedbackController.controller
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!1107 &-3408950728626638424
AnimatorStateMachine:
serializedVersion: 6
m_ObjectHideFlags: 1
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: Base Layer
m_ChildStates:
- serializedVersion: 1
m_State: {fileID: 8953144010422057453}
m_Position: {x: 210, y: 10, z: 0}
m_ChildStateMachines: []
m_AnyStateTransitions: []
m_EntryTransitions: []
m_StateMachineTransitions: {}
m_StateMachineBehaviours: []
m_AnyStatePosition: {x: 50, y: 20, z: 0}
m_EntryPosition: {x: 50, y: 120, z: 0}
m_ExitPosition: {x: 800, y: 120, z: 0}
m_ParentStateMachinePosition: {x: 800, y: 20, z: 0}
m_DefaultState: {fileID: 8953144010422057453}
--- !u!91 &9100000
AnimatorController:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: ClickFeedbackController
serializedVersion: 5
m_AnimatorParameters: []
m_AnimatorLayers:
- serializedVersion: 5
m_Name: Base Layer
m_StateMachine: {fileID: -3408950728626638424}
m_Mask: {fileID: 0}
m_Motions: []
m_Behaviours: []
m_BlendingMode: 0
m_SyncedLayerIndex: -1
m_DefaultWeight: 0
m_IKPass: 0
m_SyncedLayerAffectsTiming: 0
m_Controller: {fileID: 9100000}
--- !u!1102 &8953144010422057453
AnimatorState:
serializedVersion: 6
m_ObjectHideFlags: 1
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: UI_GroundClick
m_Speed: 1
m_CycleOffset: 0
m_Transitions: []
m_StateMachineBehaviours: []
m_Position: {x: 50, y: 50, z: 0}
m_IKOnFeet: 0
m_WriteDefaultValues: 1
m_Mirror: 0
m_SpeedParameterActive: 0
m_MirrorParameterActive: 0
m_CycleOffsetParameterActive: 0
m_TimeParameterActive: 0
m_Motion: {fileID: 7400000, guid: afc67a48ae8dfea4793e330e10545ddc, type: 2}
m_Tag:
m_SpeedParameter:
m_MirrorParameter:
m_CycleOffsetParameter:
m_TimeParameter:

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions Assets/BossRoom/Models/UI_GroundClick.anim
Git LFS file not shown
8 changes: 8 additions & 0 deletions Assets/BossRoom/Models/UI_GroundClick.anim.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 1 addition & 3 deletions Assets/BossRoom/Prefabs/Character/PlayerAvatar.prefab
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,6 @@ MonoBehaviour:
m_Name:
m_EditorClassIdentifier:
m_Animator: {fileID: 1829276847453002016}
m_ParameterSendBits: 0
m_SendRate: 0.1
--- !u!114 &7209204667172237188
MonoBehaviour:
m_ObjectHideFlags: 0
Expand Down Expand Up @@ -307,7 +305,6 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: e363085af981a41fd816ab952a0a07c7, type: 3}
m_Name:
m_EditorClassIdentifier:
m_PingIntervalSeconds: 0.1
--- !u!114 &4354133789489545025
MonoBehaviour:
m_ObjectHideFlags: 0
Expand All @@ -333,6 +330,7 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 331c67f15523ad7419792662b9768f44, type: 3}
m_Name:
m_EditorClassIdentifier:
moveRate: 0.05
m_CharacterClassContainer: {fileID: 5230418375993597025}
m_PhysicsWrapper: {fileID: 6116655102486013040}
--- !u!114 &5043718152237111612
Expand Down
114 changes: 35 additions & 79 deletions Assets/BossRoom/Prefabs/Click_Feedback.prefab
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@ GameObject:
- component: {fileID: 2500332623759108304}
- component: {fileID: 6101625250476277925}
- component: {fileID: 6375111725193425194}
- component: {fileID: 7164482062141736850}
- component: {fileID: 5754560017040867806}
- component: {fileID: 8568434976788884338}
- component: {fileID: 7961553494364404633}
m_Layer: 0
m_Name: Click_Feedback
m_TagString: Untagged
Expand All @@ -29,9 +30,8 @@ Transform:
m_GameObject: {fileID: 9137928905311479176}
m_LocalRotation: {x: 0.7071068, y: 0, z: 0, w: 0.7071068}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children:
- {fileID: 2816127936030266596}
m_LocalScale: {x: 2.713, y: 2.713, z: 2.713}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 90, y: 0, z: 0}
Expand All @@ -50,7 +50,7 @@ MeshRenderer:
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 9137928905311479176}
m_Enabled: 0
m_Enabled: 1
m_CastShadows: 1
m_ReceiveShadows: 1
m_DynamicOccludee: 1
Expand All @@ -62,7 +62,7 @@ MeshRenderer:
m_RenderingLayerMask: 1
m_RendererPriority: 0
m_Materials:
- {fileID: 10303, guid: 0000000000000000f000000000000000, type: 0}
- {fileID: 2100000, guid: bfad40b971740ef4381f47a69fd3348d, type: 2}
m_StaticBatchInfo:
firstSubMesh: 0
subMeshCount: 0
Expand All @@ -84,21 +84,39 @@ MeshRenderer:
m_SortingLayer: 0
m_SortingOrder: 0
m_AdditionalVertexStreams: {fileID: 0}
--- !u!64 &7164482062141736850
MeshCollider:
--- !u!114 &5754560017040867806
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 9137928905311479176}
m_Material: {fileID: 0}
m_IsTrigger: 0
m_Enabled: 1
serializedVersion: 4
m_Convex: 0
m_CookingOptions: 30
m_Mesh: {fileID: 10210, guid: 0000000000000000e000000000000000, type: 0}
--- !u!114 &5754560017040867806
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: b853e11fb193c8149bd7d25b17c0ddc6, type: 3}
m_Name:
m_EditorClassIdentifier:
m_DisabledDelay: 0.75
--- !u!95 &8568434976788884338
Animator:
serializedVersion: 3
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 9137928905311479176}
m_Enabled: 1
m_Avatar: {fileID: 0}
m_Controller: {fileID: 9100000, guid: 11646ef5453865d459c8ec37484dbdf3, type: 2}
m_CullingMode: 0
m_UpdateMode: 0
m_ApplyRootMotion: 0
m_LinearVelocityBlending: 0
m_WarningMessage:
m_HasTransformHierarchy: 1
m_AllowConstantClipSamplingOptimization: 1
m_KeepAnimatorControllerStateOnDisable: 0
--- !u!114 &7961553494364404633
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
Expand All @@ -107,69 +125,7 @@ MonoBehaviour:
m_GameObject: {fileID: 9137928905311479176}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: b853e11fb193c8149bd7d25b17c0ddc6, type: 3}
m_Script: {fileID: 11500000, guid: 598271baef5b1d843990b429b974205f, type: 3}
m_Name:
m_EditorClassIdentifier:
m_DisabledDelay: 0.75
--- !u!1001 &5569208290851949093
PrefabInstance:
m_ObjectHideFlags: 0
serializedVersion: 2
m_Modification:
m_TransformParent: {fileID: 2500332623759108304}
m_Modifications:
- target: {fileID: 6957808770263120477, guid: 7c2bd7eca3b96084f99aa3a945102b11, type: 3}
propertyPath: m_Name
value: GroundClickFX
objectReference: {fileID: 0}
- target: {fileID: 7664326125434658497, guid: 7c2bd7eca3b96084f99aa3a945102b11, type: 3}
propertyPath: m_RootOrder
value: 0
objectReference: {fileID: 0}
- target: {fileID: 7664326125434658497, guid: 7c2bd7eca3b96084f99aa3a945102b11, type: 3}
propertyPath: m_LocalPosition.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 7664326125434658497, guid: 7c2bd7eca3b96084f99aa3a945102b11, type: 3}
propertyPath: m_LocalPosition.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 7664326125434658497, guid: 7c2bd7eca3b96084f99aa3a945102b11, type: 3}
propertyPath: m_LocalPosition.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 7664326125434658497, guid: 7c2bd7eca3b96084f99aa3a945102b11, type: 3}
propertyPath: m_LocalRotation.w
value: 1
objectReference: {fileID: 0}
- target: {fileID: 7664326125434658497, guid: 7c2bd7eca3b96084f99aa3a945102b11, type: 3}
propertyPath: m_LocalRotation.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 7664326125434658497, guid: 7c2bd7eca3b96084f99aa3a945102b11, type: 3}
propertyPath: m_LocalRotation.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 7664326125434658497, guid: 7c2bd7eca3b96084f99aa3a945102b11, type: 3}
propertyPath: m_LocalRotation.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 7664326125434658497, guid: 7c2bd7eca3b96084f99aa3a945102b11, type: 3}
propertyPath: m_LocalEulerAnglesHint.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 7664326125434658497, guid: 7c2bd7eca3b96084f99aa3a945102b11, type: 3}
propertyPath: m_LocalEulerAnglesHint.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 7664326125434658497, guid: 7c2bd7eca3b96084f99aa3a945102b11, type: 3}
propertyPath: m_LocalEulerAnglesHint.z
value: 0
objectReference: {fileID: 0}
m_RemovedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: 7c2bd7eca3b96084f99aa3a945102b11, type: 3}
--- !u!4 &2816127936030266596 stripped
Transform:
m_CorrespondingSourceObject: {fileID: 7664326125434658497, guid: 7c2bd7eca3b96084f99aa3a945102b11, type: 3}
m_PrefabInstance: {fileID: 5569208290851949093}
m_PrefabAsset: {fileID: 0}
lerpSpeed: 0.03
9 changes: 4 additions & 5 deletions Assets/BossRoom/Scripts/Client/ClientClickFeedback.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@ public class ClientClickFeedback : NetworkBehaviour
GameObject m_FeedbackObj;

ClientInputSender m_ClientSender;

ClickFeedbackLerper m_ClickFeedbackLerper;

const float k_HoverHeight = 0.15f;

void Start()
{
Expand All @@ -30,15 +31,13 @@ void Start()
m_ClientSender.ClientMoveEvent += OnClientMove;
m_FeedbackObj = Instantiate(m_FeedbackPrefab);
m_FeedbackObj.SetActive(false);
m_ClickFeedbackLerper = m_FeedbackObj.GetComponent<ClickFeedbackLerper>();
}

void OnClientMove(Vector3 position)
{
position.y += k_HoverHeight;

m_FeedbackObj.transform.position = position;
m_FeedbackObj.SetActive(true);

m_ClickFeedbackLerper.SetTarget(position);
}

public override void OnDestroy()
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
using Unity.Multiplayer.Samples.BossRoom.Visual;
using UnityEngine;

namespace Unity.Multiplayer.Samples.BossRoom.Client
{
public class ClickFeedbackLerper : MonoBehaviour
{
PositionLerper m_PositionLerper;

Vector3 m_TargetPosition;

// The amount of offset to keep the click feedback object from intersecting with the floor
const float k_HoverHeight = 0.15f;
const float k_LerpTime = 0.04f;

void Start()
{
m_PositionLerper = new PositionLerper(Vector3.zero, k_LerpTime);
}

void Update()
{
transform.position = m_PositionLerper.LerpPosition(transform.position, m_TargetPosition);
}

public void SetTarget(Vector3 clientInputPosition)
{
m_TargetPosition.x = clientInputPosition.x;
m_TargetPosition.y = k_HoverHeight;
m_TargetPosition.z = clientInputPosition.z;
}
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ public class ClientInputSender : NetworkBehaviour
{
private const float k_MouseInputRaycastDistance = 100f;

//The movement input rate is capped at 50ms (or 20 fps). This provides a nice balance between responsiveness and
//The movement input rate is capped at 40ms (or 25 fps). This provides a nice balance between responsiveness and
//upstream network conservation. This matters when holding down your mouse button to move.
private const float k_MoveSendRateSeconds = 0.05f; //20 fps.
private const float k_MoveSendRateSeconds = 0.04f; //25 fps.


private const float k_TargetMoveTimeout = 0.45f; //prevent moves for this long after targeting someone (helps prevent walking to the guy you clicked).
Expand Down
2 changes: 1 addition & 1 deletion Assets/BossRoom/VFX/Materials/GroundClick.mat
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ Material:
- _ColorMask: 15
- _ColorMode: 3
- _Cull: 2
- _Cutoff: 0.5
- _Cutoff: 0.123
- _DetailNormalMapScale: 1
- _DiffuseAmount: 0.2
- _DistortionBlend: 0.5
Expand Down
2 changes: 1 addition & 1 deletion Assets/BossRoom/VFX/Prefabs/UI/fx_GroundClickFX.prefab
Original file line number Diff line number Diff line change
Expand Up @@ -4792,7 +4792,7 @@ ParticleSystemRenderer:
m_RenderAlignment: 1
m_Pivot: {x: 0, y: 0, z: 0}
m_Flip: {x: 0, y: 0, z: 0}
m_UseCustomVertexStreams: 1
m_UseCustomVertexStreams: 0
m_EnableGPUInstancing: 1
m_ApplyActiveColorSpace: 1
m_AllowRoll: 1
Expand Down