Commit 6b0e4e48 authored by Mitchie Maluschnig's avatar Mitchie Maluschnig
Browse files

trying a different way of structuring trapeze person

parent 5cc6a806
......@@ -7160,6 +7160,11 @@ Prefab:
propertyPath: m_RootOrder
value: 8
objectReference: {fileID: 0}
- target: {fileID: 224962148856270744, guid: a6dd0ddad611645efbc5ef92c67041a7,
type: 2}
propertyPath: m_LocalPosition.z
value: 0
objectReference: {fileID: 0}
m_RemovedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: a6dd0ddad611645efbc5ef92c67041a7, type: 2}
m_IsPrefabAsset: 0
......@@ -7727,6 +7732,81 @@ Canvas:
m_SortingLayerID: -1020251125
m_SortingOrder: 2
m_TargetDisplay: 0
--- !u!1 &1977796532
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 1977796534}
- component: {fileID: 1977796533}
m_Layer: 0
m_Name: cole tent
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!212 &1977796533
SpriteRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 1977796532}
m_Enabled: 1
m_CastShadows: 0
m_ReceiveShadows: 0
m_DynamicOccludee: 1
m_MotionVectors: 1
m_LightProbeUsage: 1
m_ReflectionProbeUsage: 1
m_RenderingLayerMask: 4294967295
m_Materials:
- {fileID: 10754, guid: 0000000000000000f000000000000000, type: 0}
m_StaticBatchInfo:
firstSubMesh: 0
subMeshCount: 0
m_StaticBatchRoot: {fileID: 0}
m_ProbeAnchor: {fileID: 0}
m_LightProbeVolumeOverride: {fileID: 0}
m_ScaleInLightmap: 1
m_PreserveUVs: 0
m_IgnoreNormalsForChartDetection: 0
m_ImportantGI: 0
m_StitchLightmapSeams: 0
m_SelectedEditorRenderState: 0
m_MinimumChartSize: 4
m_AutoUVMaxDistance: 0.5
m_AutoUVMaxAngle: 89
m_LightmapParameters: {fileID: 0}
m_SortingLayerID: -1106870113
m_SortingLayer: 1
m_SortingOrder: 1
m_Sprite: {fileID: 21300000, guid: 9dcfcb216d85dd449816699afb0499e6, type: 3}
m_Color: {r: 1, g: 1, b: 1, a: 1}
m_FlipX: 0
m_FlipY: 0
m_DrawMode: 0
m_Size: {x: 10, y: 5}
m_AdaptiveModeThreshold: 0.5
m_SpriteTileMode: 0
m_WasSpriteAssigned: 1
m_MaskInteraction: 0
m_SpriteSortPoint: 0
--- !u!4 &1977796534
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 1977796532}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 14.555, y: 1.26, z: 0}
m_LocalScale: {x: 2.5099998, y: 2.15, z: 1}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 9
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &2138223314
GameObject:
m_ObjectHideFlags: 0
......
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class HandsTrigger : MonoBehaviour {
private TrapezePerson trapezePerson;
// Use this for initialization
void Start () {
trapezePerson = GetComponentInParent<TrapezePerson>();
}
// Update is called once per frame
void Update () {
}
void OnTriggerEnter2D(Collider2D collision) {
if (collision.gameObject.layer == LayerMask.NameToLayer("Key")) {
print("Collision");
if (!trapezePerson.onTrapeze) {
trapezePerson.AttachToTrapeze(collision.gameObject);
}
}
}
}
fileFormatVersion: 2
guid: e8199870fdccbda429d8da476630df26
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
......@@ -3,17 +3,21 @@ using System.Collections.Generic;
using UnityEngine;
public class RotateTests : MonoBehaviour {
public float swingForce = 0.5f;
public float swingForce = 1f;
public float rotateForce = 1f;
public float exitForce = 3;
public Transform topPivot;
public Transform handsPivot;
public Transform MidPivot;
public Transform botPivot;
private HingeJoint2D hinge;
private Rigidbody2D body;
private Transform currentPivot;
private bool onTrapeze;
[HideInInspector]
public Transform currentPivot;
[HideInInspector]
public bool onTrapeze;
private GameObject currentTrapeze;
private float linearVelocity;
......@@ -28,11 +32,20 @@ public class RotateTests : MonoBehaviour {
// Update is called once per frame
void Update () {
if (Input.GetKey(KeyCode.D)) {
//transform.RotateAround(currentPivot.position, Vector3.forward, 10);
body.AddTorque(swingForce / 10);
if (onTrapeze) {
body.AddTorque(swingForce / 10);
} else {
body.rotation = 0;
transform.RotateAround(currentPivot.position, Vector3.forward, rotateForce);
}
}
if (Input.GetKey(KeyCode.A)) {
body.AddTorque(-swingForce / 10);
if (onTrapeze) {
body.AddTorque(-swingForce / 10);
} else {
body.rotation = 0;
transform.RotateAround(currentPivot.position, Vector3.forward, -rotateForce);
}
}
if (Input.GetKeyDown(KeyCode.Space)) {
DetachFromTrapeze();
......@@ -42,15 +55,6 @@ public class RotateTests : MonoBehaviour {
linearVelocity = radius * radiansPerSecond;
}
void OnTriggerEnter2D(Collider2D collision) {
if (collision.gameObject.layer == LayerMask.NameToLayer("Key")) {
print("Collision");
if (!onTrapeze) {
AttachToTrapeze(collision.gameObject);
}
}
}
private void OnTriggerExit2D(Collider2D collision) {
print("exit");
......@@ -58,16 +62,20 @@ public class RotateTests : MonoBehaviour {
public void AttachToTrapeze(GameObject trapeze) {
onTrapeze = true;
currentPivot = transform;
currentPivot = handsPivot;
hinge.enabled = true;
currentTrapeze = trapeze;
Time.timeScale = 1;
swingForce /= 2;
}
public void DetachFromTrapeze() {
currentPivot = botPivot;
currentPivot = MidPivot;
hinge.enabled = false;
onTrapeze = false;
body.velocity = linearVelocity * exitForce * transform.right;
currentTrapeze.GetComponent<CapsuleCollider2D>().enabled = false;
//currentTrapeze.GetComponent<CapsuleCollider2D>().enabled = false;
Time.timeScale = 0.5f;
swingForce *= 2;
}
}
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class TrapezeCameraFollow : MonoBehaviour {
private GameObject player;
private TrapezePerson playerScript;
// Use this for initialization
void Start () {
player = GameObject.FindWithTag("Player");
playerScript = player.GetComponent<TrapezePerson>();
}
// Update is called once per frame
void Update () {
Vector3 playerPos = playerScript.currentPivot.position;
playerPos.z = Camera.main.transform.position.z;
Camera.main.transform.position = playerPos;
}
}
fileFormatVersion: 2
guid: 1d0fbef5ac9d4da4abd5ea0fb501c48e
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class TrapezePerson : MonoBehaviour {
public float swingForce = 1f;
public float rotateForce = 1f;
public float exitForce = 3;
public Transform handsPivot;
public Transform midPivot;
public Transform botPivot;
private HingeJoint2D hinge;
private Rigidbody2D body;
[HideInInspector]
public Transform currentPivot;
[HideInInspector]
public bool onTrapeze;
private GameObject currentTrapeze;
private float linearVelocity;
// Use this for initialization
void Start () {
currentPivot = midPivot;
hinge = GetComponent<HingeJoint2D>();
body = GetComponent<Rigidbody2D>();
}
// Update is called once per frame
void Update () {
if (Input.GetKey(KeyCode.D)) {
if (onTrapeze) {
body.AddTorque(swingForce / 10);
} else {
transform.RotateAround(currentPivot.position, Vector3.forward, -rotateForce);
}
}
if (Input.GetKey(KeyCode.A)) {
if (onTrapeze) {
body.AddTorque(-swingForce / 10);
} else {
transform.RotateAround(currentPivot.position, Vector3.forward, rotateForce);
}
}
if (Input.GetKeyDown(KeyCode.Space)) {
float radius = Vector3.Distance(transform.position, botPivot.position);
float radiansPerSecond = body.angularVelocity * Mathf.PI / 180;
linearVelocity = radius * radiansPerSecond;
DetachFromTrapeze();
}
}
//void OnTriggerEnter2D(Collider2D collision) {
// if (collision.gameObject.layer == LayerMask.NameToLayer("Key")) {
// print("Collision");
// if (!onTrapeze) {
// AttachToTrapeze(collision.gameObject);
// }
// }
//}
public void AttachToTrapeze(GameObject trapeze) {
onTrapeze = true;
currentPivot = handsPivot;
hinge.enabled = true;
//GetComponent<CapsuleCollider2D>().enabled = true;
currentTrapeze = trapeze;
Time.timeScale = 1;
swingForce /= 2;
}
public void DetachFromTrapeze() {
currentPivot = midPivot;
hinge.enabled = false;
onTrapeze = false;
body.velocity = linearVelocity * exitForce * transform.right;
//currentTrapeze.GetComponent<CapsuleCollider2D>().enabled = false;
//GetComponent<CapsuleCollider2D>().enabled = false;
Time.timeScale = 0.5f;
swingForce *= 2;
body.angularVelocity = 0;
}
}
fileFormatVersion: 2
guid: 61a7a661e35442f4bb1fd1c59879f27b
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
fileFormatVersion: 2
guid: 9dcfcb216d85dd449816699afb0499e6
TextureImporter:
fileIDToRecycleName: {}
externalObjects: {}
serializedVersion: 7
mipmaps:
mipMapMode: 0
enableMipMap: 0
sRGBTexture: 1
linearTexture: 0
fadeOut: 0
borderMipMap: 0
mipMapsPreserveCoverage: 0
alphaTestReferenceValue: 0.5
mipMapFadeDistanceStart: 1
mipMapFadeDistanceEnd: 3
bumpmap:
convertToNormalMap: 0
externalNormalMap: 0
heightScale: 0.25
normalMapFilter: 0
isReadable: 0
streamingMipmaps: 0
streamingMipmapsPriority: 0
grayScaleToAlpha: 0
generateCubemap: 6
cubemapConvolution: 0
seamlessCubemap: 0
textureFormat: 1
maxTextureSize: 2048
textureSettings:
serializedVersion: 2
filterMode: -1
aniso: -1
mipBias: -100
wrapU: 1
wrapV: 1
wrapW: 1
nPOTScale: 0
lightmap: 0
compressionQuality: 50
spriteMode: 1
spriteExtrude: 1
spriteMeshType: 1
alignment: 0
spritePivot: {x: 0.5, y: 0.5}
spritePixelsToUnits: 100
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
spriteGenerateFallbackPhysicsShape: 1
alphaUsage: 1
alphaIsTransparency: 1
spriteTessellationDetail: -1
textureType: 8
textureShape: 1
singleChannelComponent: 0
maxTextureSizeSet: 0
compressionQualitySet: 0
textureFormatSet: 0
platformSettings:
- serializedVersion: 2
buildTarget: DefaultTexturePlatform
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
spriteSheet:
serializedVersion: 2
sprites: []
outline: []
physicsShape: []
bones: []
spriteID: 10cc4ed2ab5f68842b035c7fcd08dba6
vertices: []
indices:
edges: []
weights: []
spritePackingTag:
pSDRemoveMatte: 0
pSDShowRemoveMatteOption: 0
userData:
assetBundleName:
assetBundleVariant:
m_EditorVersion: 2018.2.12f1
m_EditorVersion: 2018.2.11f1
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment