feedback addressed
This commit is contained in:
@@ -529,7 +529,7 @@ Rigidbody2D:
|
||||
m_Interpolate: 0
|
||||
m_SleepingMode: 1
|
||||
m_CollisionDetection: 0
|
||||
m_Constraints: 0
|
||||
m_Constraints: 4
|
||||
--- !u!58 &2738569492822449184
|
||||
CircleCollider2D:
|
||||
m_ObjectHideFlags: 0
|
||||
@@ -588,3 +588,4 @@ MonoBehaviour:
|
||||
markerRotateSpeed: 30
|
||||
markerBounceIntensity: 0.025
|
||||
markerBounceSpeed: 5
|
||||
lineEnd: {x: 0, y: 0, z: 0}
|
||||
|
||||
@@ -254,3 +254,13 @@ MonoBehaviour:
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
rb: {fileID: 0}
|
||||
wallDetectionLength: 0.25
|
||||
wallStuckFixForce: 500
|
||||
maxWallStuckVelocity: 5
|
||||
wallLayerMask:
|
||||
serializedVersion: 2
|
||||
m_Bits: 64
|
||||
touchingB: 0
|
||||
touchingL: 0
|
||||
touchingR: 0
|
||||
touchingT: 0
|
||||
|
||||
@@ -9,6 +9,6 @@ PhysicsMaterial2D:
|
||||
m_Name: Puck
|
||||
serializedVersion: 2
|
||||
friction: 1
|
||||
bounciness: 0.5
|
||||
bounciness: 0.2
|
||||
m_FrictionCombine: 3
|
||||
m_BounceCombine: 4
|
||||
|
||||
@@ -151,7 +151,7 @@ MonoBehaviour:
|
||||
m_Script: {fileID: 11500000, guid: f5ca0ff31c184b04da729df1fae08a5e, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
team: 0
|
||||
team: 1
|
||||
--- !u!61 &17454383
|
||||
BoxCollider2D:
|
||||
m_ObjectHideFlags: 0
|
||||
@@ -243,7 +243,7 @@ SpriteRenderer:
|
||||
m_SortingLayer: 0
|
||||
m_SortingOrder: 0
|
||||
m_Sprite: {fileID: 7482667652216324306, guid: 311925a002f4447b3a28927169b83ea6, type: 3}
|
||||
m_Color: {r: 1, g: 1, b: 1, a: 0.03529412}
|
||||
m_Color: {r: 1, g: 1, b: 1, a: 0}
|
||||
m_FlipX: 0
|
||||
m_FlipY: 0
|
||||
m_DrawMode: 0
|
||||
@@ -262,8 +262,8 @@ Transform:
|
||||
m_GameObject: {fileID: 17454381}
|
||||
serializedVersion: 2
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalPosition: {x: -0.0146, y: -5.009, z: 0}
|
||||
m_LocalScale: {x: 1.7868928, y: 0.80566067, z: 1}
|
||||
m_LocalPosition: {x: -0.0146, y: -5.1408, z: 0}
|
||||
m_LocalScale: {x: 1.7868928, y: 0.5420485, z: 1}
|
||||
m_ConstrainProportionsScale: 0
|
||||
m_Children: []
|
||||
m_Father: {fileID: 0}
|
||||
@@ -873,6 +873,10 @@ PrefabInstance:
|
||||
serializedVersion: 3
|
||||
m_TransformParent: {fileID: 0}
|
||||
m_Modifications:
|
||||
- target: {fileID: 5896139376663135640, guid: c3a9beee82147c54b960a10faf404e0f, type: 3}
|
||||
propertyPath: m_CollisionDetection
|
||||
value: 1
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 7377873967498557941, guid: c3a9beee82147c54b960a10faf404e0f, type: 3}
|
||||
propertyPath: m_LocalScale.x
|
||||
value: 0.5
|
||||
@@ -945,9 +949,9 @@ GameObject:
|
||||
- component: {fileID: 365494167}
|
||||
- component: {fileID: 365494166}
|
||||
- component: {fileID: 365494165}
|
||||
m_Layer: 0
|
||||
m_Layer: 6
|
||||
m_Name: t (14)
|
||||
m_TagString: Untagged
|
||||
m_TagString: wall
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
@@ -1163,6 +1167,10 @@ PrefabInstance:
|
||||
serializedVersion: 3
|
||||
m_TransformParent: {fileID: 0}
|
||||
m_Modifications:
|
||||
- target: {fileID: 5896139376663135640, guid: c3a9beee82147c54b960a10faf404e0f, type: 3}
|
||||
propertyPath: m_CollisionDetection
|
||||
value: 1
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 7377873967498557941, guid: c3a9beee82147c54b960a10faf404e0f, type: 3}
|
||||
propertyPath: m_LocalScale.x
|
||||
value: 0.5
|
||||
@@ -1235,9 +1243,9 @@ GameObject:
|
||||
- component: {fileID: 437751835}
|
||||
- component: {fileID: 437751834}
|
||||
- component: {fileID: 437751833}
|
||||
m_Layer: 0
|
||||
m_Layer: 6
|
||||
m_Name: t (4)
|
||||
m_TagString: Untagged
|
||||
m_TagString: wall
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
@@ -1390,7 +1398,7 @@ MonoBehaviour:
|
||||
m_Script: {fileID: 11500000, guid: f5ca0ff31c184b04da729df1fae08a5e, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
team: 1
|
||||
team: 0
|
||||
--- !u!61 &467609674
|
||||
BoxCollider2D:
|
||||
m_ObjectHideFlags: 0
|
||||
@@ -1482,7 +1490,7 @@ SpriteRenderer:
|
||||
m_SortingLayer: 0
|
||||
m_SortingOrder: 0
|
||||
m_Sprite: {fileID: 7482667652216324306, guid: 311925a002f4447b3a28927169b83ea6, type: 3}
|
||||
m_Color: {r: 1, g: 1, b: 1, a: 0.03529412}
|
||||
m_Color: {r: 1, g: 1, b: 1, a: 0}
|
||||
m_FlipX: 0
|
||||
m_FlipY: 0
|
||||
m_DrawMode: 0
|
||||
@@ -1501,8 +1509,8 @@ Transform:
|
||||
m_GameObject: {fileID: 467609672}
|
||||
serializedVersion: 2
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalPosition: {x: -0.0146, y: 4.8676, z: 0}
|
||||
m_LocalScale: {x: 1.7868928, y: 0.80566067, z: 1}
|
||||
m_LocalPosition: {x: -0.0146, y: 5.0199, z: 0}
|
||||
m_LocalScale: {x: 1.7868928, y: 0.501039, z: 1}
|
||||
m_ConstrainProportionsScale: 0
|
||||
m_Children: []
|
||||
m_Father: {fileID: 0}
|
||||
@@ -1545,9 +1553,9 @@ GameObject:
|
||||
- component: {fileID: 506521094}
|
||||
- component: {fileID: 506521093}
|
||||
- component: {fileID: 506521092}
|
||||
m_Layer: 0
|
||||
m_Layer: 6
|
||||
m_Name: t
|
||||
m_TagString: Untagged
|
||||
m_TagString: wall
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
@@ -1900,9 +1908,9 @@ GameObject:
|
||||
- component: {fileID: 663560861}
|
||||
- component: {fileID: 663560863}
|
||||
- component: {fileID: 663560862}
|
||||
m_Layer: 0
|
||||
m_Layer: 6
|
||||
m_Name: t (7)
|
||||
m_TagString: Untagged
|
||||
m_TagString: wall
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
@@ -2170,9 +2178,9 @@ GameObject:
|
||||
- component: {fileID: 715560525}
|
||||
- component: {fileID: 715560524}
|
||||
- component: {fileID: 715560523}
|
||||
m_Layer: 0
|
||||
m_Layer: 6
|
||||
m_Name: t (1)
|
||||
m_TagString: Untagged
|
||||
m_TagString: wall
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
@@ -2309,6 +2317,10 @@ PrefabInstance:
|
||||
propertyPath: m_IsActive
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 5896139376663135640, guid: c3a9beee82147c54b960a10faf404e0f, type: 3}
|
||||
propertyPath: m_CollisionDetection
|
||||
value: 1
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 7377873967498557941, guid: c3a9beee82147c54b960a10faf404e0f, type: 3}
|
||||
propertyPath: m_LocalScale.x
|
||||
value: 0.5
|
||||
@@ -2390,6 +2402,10 @@ PrefabInstance:
|
||||
propertyPath: m_IsActive
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 5896139376663135640, guid: c3a9beee82147c54b960a10faf404e0f, type: 3}
|
||||
propertyPath: m_CollisionDetection
|
||||
value: 1
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 7377873967498557941, guid: c3a9beee82147c54b960a10faf404e0f, type: 3}
|
||||
propertyPath: m_LocalScale.x
|
||||
value: 0.5
|
||||
@@ -2553,9 +2569,9 @@ GameObject:
|
||||
- component: {fileID: 846159459}
|
||||
- component: {fileID: 846159458}
|
||||
- component: {fileID: 846159457}
|
||||
m_Layer: 0
|
||||
m_Layer: 6
|
||||
m_Name: t (13)
|
||||
m_TagString: Untagged
|
||||
m_TagString: wall
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
@@ -3082,9 +3098,9 @@ GameObject:
|
||||
- component: {fileID: 1041309955}
|
||||
- component: {fileID: 1041309954}
|
||||
- component: {fileID: 1041309953}
|
||||
m_Layer: 0
|
||||
m_Layer: 6
|
||||
m_Name: t (2)
|
||||
m_TagString: Untagged
|
||||
m_TagString: wall
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
@@ -3216,9 +3232,9 @@ GameObject:
|
||||
- component: {fileID: 1053260090}
|
||||
- component: {fileID: 1053260089}
|
||||
- component: {fileID: 1053260088}
|
||||
m_Layer: 0
|
||||
m_Layer: 6
|
||||
m_Name: t (3)
|
||||
m_TagString: Untagged
|
||||
m_TagString: wall
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
@@ -3593,7 +3609,7 @@ GameObject:
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 1135439587}
|
||||
m_Layer: 0
|
||||
m_Layer: 6
|
||||
m_Name: walls
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
@@ -3740,6 +3756,10 @@ PrefabInstance:
|
||||
serializedVersion: 3
|
||||
m_TransformParent: {fileID: 0}
|
||||
m_Modifications:
|
||||
- target: {fileID: 5896139376663135640, guid: c3a9beee82147c54b960a10faf404e0f, type: 3}
|
||||
propertyPath: m_CollisionDetection
|
||||
value: 1
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 7377873967498557941, guid: c3a9beee82147c54b960a10faf404e0f, type: 3}
|
||||
propertyPath: m_LocalScale.x
|
||||
value: 0.5
|
||||
@@ -3901,9 +3921,9 @@ GameObject:
|
||||
- component: {fileID: 1365639911}
|
||||
- component: {fileID: 1365639913}
|
||||
- component: {fileID: 1365639912}
|
||||
m_Layer: 0
|
||||
m_Layer: 6
|
||||
m_Name: t (9)
|
||||
m_TagString: Untagged
|
||||
m_TagString: wall
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
@@ -4040,6 +4060,10 @@ PrefabInstance:
|
||||
propertyPath: m_IsActive
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 5896139376663135640, guid: c3a9beee82147c54b960a10faf404e0f, type: 3}
|
||||
propertyPath: m_CollisionDetection
|
||||
value: 1
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 7377873967498557941, guid: c3a9beee82147c54b960a10faf404e0f, type: 3}
|
||||
propertyPath: m_LocalScale.x
|
||||
value: 0.5
|
||||
@@ -4113,6 +4137,10 @@ PrefabInstance:
|
||||
serializedVersion: 3
|
||||
m_TransformParent: {fileID: 0}
|
||||
m_Modifications:
|
||||
- target: {fileID: 5896139376663135640, guid: c3a9beee82147c54b960a10faf404e0f, type: 3}
|
||||
propertyPath: m_CollisionDetection
|
||||
value: 1
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 7377873967498557941, guid: c3a9beee82147c54b960a10faf404e0f, type: 3}
|
||||
propertyPath: m_LocalScale.x
|
||||
value: 0.5
|
||||
@@ -4359,9 +4387,9 @@ GameObject:
|
||||
- component: {fileID: 1505444918}
|
||||
- component: {fileID: 1505444920}
|
||||
- component: {fileID: 1505444919}
|
||||
m_Layer: 0
|
||||
m_Layer: 6
|
||||
m_Name: t (8)
|
||||
m_TagString: Untagged
|
||||
m_TagString: wall
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
@@ -4636,6 +4664,10 @@ PrefabInstance:
|
||||
serializedVersion: 3
|
||||
m_TransformParent: {fileID: 0}
|
||||
m_Modifications:
|
||||
- target: {fileID: 5896139376663135640, guid: c3a9beee82147c54b960a10faf404e0f, type: 3}
|
||||
propertyPath: m_CollisionDetection
|
||||
value: 1
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 7377873967498557941, guid: c3a9beee82147c54b960a10faf404e0f, type: 3}
|
||||
propertyPath: m_LocalScale.x
|
||||
value: 0.5
|
||||
@@ -4744,7 +4776,8 @@ MonoBehaviour:
|
||||
m_isMoving: 0
|
||||
gameInputPanel: {fileID: 1302593952}
|
||||
ball: {fileID: 2066222788}
|
||||
puckForce: 30
|
||||
puckForce: 5000
|
||||
puckForceMaxPoint: 0.75
|
||||
ballMoveTime: 5
|
||||
puckDragClamp: 3
|
||||
redScore: 0
|
||||
@@ -4846,9 +4879,9 @@ GameObject:
|
||||
- component: {fileID: 1771907449}
|
||||
- component: {fileID: 1771907448}
|
||||
- component: {fileID: 1771907447}
|
||||
m_Layer: 0
|
||||
m_Layer: 6
|
||||
m_Name: t (6)
|
||||
m_TagString: Untagged
|
||||
m_TagString: wall
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
@@ -5352,9 +5385,9 @@ GameObject:
|
||||
- component: {fileID: 1953647371}
|
||||
- component: {fileID: 1953647370}
|
||||
- component: {fileID: 1953647369}
|
||||
m_Layer: 0
|
||||
m_Layer: 6
|
||||
m_Name: t (5)
|
||||
m_TagString: Untagged
|
||||
m_TagString: wall
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
@@ -5491,6 +5524,10 @@ PrefabInstance:
|
||||
propertyPath: m_IsActive
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 5896139376663135640, guid: c3a9beee82147c54b960a10faf404e0f, type: 3}
|
||||
propertyPath: m_CollisionDetection
|
||||
value: 1
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 7377873967498557941, guid: c3a9beee82147c54b960a10faf404e0f, type: 3}
|
||||
propertyPath: m_LocalScale.x
|
||||
value: 0.5
|
||||
@@ -5659,6 +5696,10 @@ PrefabInstance:
|
||||
propertyPath: m_IsActive
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 5896139376663135640, guid: c3a9beee82147c54b960a10faf404e0f, type: 3}
|
||||
propertyPath: m_CollisionDetection
|
||||
value: 1
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 7377873967498557941, guid: c3a9beee82147c54b960a10faf404e0f, type: 3}
|
||||
propertyPath: m_LocalScale.x
|
||||
value: 0.5
|
||||
|
||||
@@ -5,7 +5,10 @@ public class Ball : MonoBehaviour
|
||||
{
|
||||
[HideInInspector]public Rigidbody2D rb;
|
||||
Vector3 startPosition;
|
||||
|
||||
public float wallDetectionLength = 0.5f;
|
||||
public float wallStuckFixForce = 1f;
|
||||
public float maxWallStuckVelocity = 5f;
|
||||
public LayerMask wallLayerMask;
|
||||
void Awake()
|
||||
{
|
||||
rb = GetComponent<Rigidbody2D>();
|
||||
@@ -26,4 +29,61 @@ public class Ball : MonoBehaviour
|
||||
yield return null;
|
||||
}
|
||||
}
|
||||
|
||||
public bool touchingB,touchingL,touchingR,touchingT = false;
|
||||
void Update()
|
||||
{
|
||||
WallDetection();
|
||||
}
|
||||
void OnCollisionEnter2D(Collision2D collision)
|
||||
{
|
||||
float otherSpeed = collision.relativeVelocity.magnitude;
|
||||
float velocityMult = 1- Mathf.Clamp01(rb.linearVelocity.magnitude / maxWallStuckVelocity);
|
||||
|
||||
Debug.Log($"{collision.collider.name} hit ball @ {otherSpeed}, ball speed: {rb.linearVelocity.magnitude}");
|
||||
if (touchingR) {
|
||||
rb.AddForce(Vector2.left * otherSpeed *wallStuckFixForce * velocityMult * Time.deltaTime);
|
||||
}
|
||||
if (touchingL) {
|
||||
rb.AddForce(Vector2.right * otherSpeed * wallStuckFixForce * velocityMult * Time.deltaTime);
|
||||
}
|
||||
if (touchingT) {
|
||||
rb.AddForce(Vector2.down * otherSpeed * wallStuckFixForce * velocityMult * Time.deltaTime);
|
||||
}
|
||||
if (touchingB) {
|
||||
rb.AddForce(Vector2.up *otherSpeed * wallStuckFixForce * velocityMult * Time.deltaTime);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void WallDetection(){
|
||||
// Linecast for each direction
|
||||
Vector3 pos = transform.position;
|
||||
|
||||
RaycastHit2D hitL = Physics2D.Linecast(pos, pos + Vector3.left * wallDetectionLength, wallLayerMask);
|
||||
touchingL = hitL.collider != null;
|
||||
|
||||
RaycastHit2D hitR = Physics2D.Linecast(pos, pos + Vector3.right * wallDetectionLength, wallLayerMask);
|
||||
touchingR = hitR.collider != null;
|
||||
|
||||
RaycastHit2D hitT = Physics2D.Linecast(pos, pos + Vector3.up * wallDetectionLength, wallLayerMask);
|
||||
touchingT = hitT.collider != null;
|
||||
|
||||
RaycastHit2D hitB = Physics2D.Linecast(pos, pos + Vector3.down * wallDetectionLength, wallLayerMask);
|
||||
touchingB = hitB.collider != null;
|
||||
}
|
||||
void OnDrawGizmos()
|
||||
{
|
||||
Gizmos.color = touchingL ? Color.red : Color.green;
|
||||
Gizmos.DrawLine(transform.position, transform.position + (Vector3.left * wallDetectionLength));
|
||||
|
||||
Gizmos.color = touchingR ? Color.red : Color.green;
|
||||
Gizmos.DrawLine(transform.position, transform.position + (Vector3.right * wallDetectionLength));
|
||||
|
||||
Gizmos.color = touchingT ? Color.red : Color.green;
|
||||
Gizmos.DrawLine(transform.position, transform.position + (Vector3.up * wallDetectionLength));
|
||||
|
||||
Gizmos.color = touchingB ? Color.red : Color.green;
|
||||
Gizmos.DrawLine(transform.position, transform.position + (Vector3.down * wallDetectionLength));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,7 +23,9 @@ public class GameManager : MonoBehaviour
|
||||
}
|
||||
public EventTrigger gameInputPanel;
|
||||
public Rigidbody2D ball;
|
||||
public float puckForce = 1f;
|
||||
public float puckForce = 20f;
|
||||
[Range(0f,1f)]
|
||||
public float puckForceMaxPoint = 0.75f;
|
||||
public float ballMoveTime = 3f;
|
||||
public float puckDragClamp = 5f;
|
||||
|
||||
@@ -114,13 +116,16 @@ public class GameManager : MonoBehaviour
|
||||
Debug.Log("Pointer up");
|
||||
PointerEventData pointerEventData = eventData as PointerEventData;
|
||||
Vector2 endPosition = pointerEventData.position;
|
||||
Vector2 direction = endPosition - startPosition;
|
||||
// Vector2 direction = endPosition - startPosition;
|
||||
Vector2 direction = selectedPuck.lineEnd;
|
||||
if(coroutinePostLaunch != null){
|
||||
StopCoroutine(coroutinePostLaunch);
|
||||
}
|
||||
coroutinePostLaunch = StartCoroutine(CoroutinePostLaunch());
|
||||
|
||||
selectedPuck.GetComponent<Rigidbody2D>().AddForce(-direction * puckForce * Time.deltaTime, ForceMode2D.Impulse);
|
||||
float force = puckForce * Time.deltaTime;
|
||||
Debug.Log($"launching puck at {direction}");
|
||||
selectedPuck.GetComponent<Rigidbody2D>().AddForce(-direction * force, ForceMode2D.Impulse);
|
||||
|
||||
startPosition = Vector2.zero;
|
||||
selectedPuck = null;
|
||||
@@ -169,7 +174,7 @@ public class GameManager : MonoBehaviour
|
||||
public void OnGoal(Team team){
|
||||
freezeInput=true;
|
||||
|
||||
if(team == SelectedTeam){
|
||||
if(team == Team.Blue){
|
||||
blueScore++;
|
||||
blueScoreText.text = blueScore.ToString();
|
||||
}else{
|
||||
|
||||
@@ -6,7 +6,7 @@ public class Goal : MonoBehaviour
|
||||
void OnTriggerEnter2D(Collider2D collision)
|
||||
{
|
||||
if(collision.gameObject.CompareTag("Player")){
|
||||
Debug.Log("GOAL!");
|
||||
Debug.Log($"GOAL! {team.ToString()}", gameObject);
|
||||
Ball ball = collision.gameObject.GetComponent<Ball>();
|
||||
Debug.Log(ball.name);
|
||||
GameManager.instance.OnGoal(team);
|
||||
|
||||
@@ -51,21 +51,21 @@ public class Puck : MonoBehaviour
|
||||
|
||||
GameManager.instance.DisposePuck(this);
|
||||
}
|
||||
|
||||
public Vector3 lineEnd;
|
||||
void Update()
|
||||
{
|
||||
if (isSelected && lineRenderer != null)
|
||||
{
|
||||
Vector3 worldEnd = Camera.main.ScreenToWorldPoint(new Vector3(GameManager.instance.curPosition.x, GameManager.instance.curPosition.y, Camera.main.nearClipPlane));
|
||||
|
||||
Vector3 localEnd = transform.InverseTransformPoint(worldEnd);
|
||||
lineEnd = transform.InverseTransformPoint(worldEnd);
|
||||
float clamp = GameManager.instance.puckDragClamp;
|
||||
localEnd = Vector2.ClampMagnitude(localEnd, clamp);
|
||||
lineEnd = Vector2.ClampMagnitude(lineEnd, clamp);
|
||||
|
||||
// Only two points for the line
|
||||
lineRenderer.positionCount = 2;
|
||||
lineRenderer.SetPosition(0, Vector3.zero);
|
||||
lineRenderer.SetPosition(1, new Vector3(localEnd.x, localEnd.y, 0));
|
||||
lineRenderer.SetPosition(1, new Vector3(lineEnd.x, lineEnd.y, 0));
|
||||
}
|
||||
|
||||
selectedMarker.gameObject.SetActive(GetMarkerVisibility());
|
||||
|
||||
@@ -9,6 +9,6 @@ PhysicsMaterial2D:
|
||||
m_Name: Wall
|
||||
serializedVersion: 2
|
||||
friction: 0
|
||||
bounciness: 0.8
|
||||
bounciness: 0.5
|
||||
m_FrictionCombine: 3
|
||||
m_BounceCombine: 4
|
||||
|
||||
Reference in New Issue
Block a user