Debut test grab
This commit is contained in:
parent
509d9e42cd
commit
3ab91fb604
2 changed files with 154 additions and 6 deletions
|
@ -207,6 +207,116 @@ Transform:
|
||||||
m_Father: {fileID: 0}
|
m_Father: {fileID: 0}
|
||||||
m_RootOrder: 0
|
m_RootOrder: 0
|
||||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||||
|
--- !u!1 &698542424
|
||||||
|
GameObject:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
serializedVersion: 6
|
||||||
|
m_Component:
|
||||||
|
- component: {fileID: 698542427}
|
||||||
|
- component: {fileID: 698542426}
|
||||||
|
- component: {fileID: 698542425}
|
||||||
|
m_Layer: 0
|
||||||
|
m_Name: Chicken
|
||||||
|
m_TagString: Untagged
|
||||||
|
m_Icon: {fileID: 0}
|
||||||
|
m_NavMeshLayer: 0
|
||||||
|
m_StaticEditorFlags: 0
|
||||||
|
m_IsActive: 1
|
||||||
|
--- !u!61 &698542425
|
||||||
|
BoxCollider2D:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 698542424}
|
||||||
|
m_Enabled: 1
|
||||||
|
m_Density: 1
|
||||||
|
m_Material: {fileID: 0}
|
||||||
|
m_IsTrigger: 1
|
||||||
|
m_UsedByEffector: 0
|
||||||
|
m_UsedByComposite: 0
|
||||||
|
m_Offset: {x: -0.045565188, y: 0.14445162}
|
||||||
|
m_SpriteTilingProperty:
|
||||||
|
border: {x: 0, y: 0, z: 0, w: 0}
|
||||||
|
pivot: {x: 0.5, y: 0}
|
||||||
|
oldSize: {x: 0.64, y: 0.64}
|
||||||
|
newSize: {x: 0.64, y: 0.64}
|
||||||
|
adaptiveTilingThreshold: 0.5
|
||||||
|
drawMode: 0
|
||||||
|
adaptiveTiling: 0
|
||||||
|
m_AutoTiling: 0
|
||||||
|
serializedVersion: 2
|
||||||
|
m_Size: {x: 0.29235482, y: 0.28890324}
|
||||||
|
m_EdgeRadius: 0
|
||||||
|
--- !u!212 &698542426
|
||||||
|
SpriteRenderer:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 698542424}
|
||||||
|
m_Enabled: 1
|
||||||
|
m_CastShadows: 0
|
||||||
|
m_ReceiveShadows: 0
|
||||||
|
m_DynamicOccludee: 1
|
||||||
|
m_MotionVectors: 1
|
||||||
|
m_LightProbeUsage: 1
|
||||||
|
m_ReflectionProbeUsage: 1
|
||||||
|
m_RayTracingMode: 0
|
||||||
|
m_RayTraceProcedural: 0
|
||||||
|
m_RenderingLayerMask: 1
|
||||||
|
m_RendererPriority: 0
|
||||||
|
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_ReceiveGI: 1
|
||||||
|
m_PreserveUVs: 0
|
||||||
|
m_IgnoreNormalsForChartDetection: 0
|
||||||
|
m_ImportantGI: 0
|
||||||
|
m_StitchLightmapSeams: 1
|
||||||
|
m_SelectedEditorRenderState: 0
|
||||||
|
m_MinimumChartSize: 4
|
||||||
|
m_AutoUVMaxDistance: 0.5
|
||||||
|
m_AutoUVMaxAngle: 89
|
||||||
|
m_LightmapParameters: {fileID: 0}
|
||||||
|
m_SortingLayerID: 0
|
||||||
|
m_SortingLayer: 0
|
||||||
|
m_SortingOrder: 0
|
||||||
|
m_Sprite: {fileID: -1409076352009621259, guid: 02e943da6e155874dbabb79c35c05b82,
|
||||||
|
type: 3}
|
||||||
|
m_Color: {r: 1, g: 1, b: 1, a: 1}
|
||||||
|
m_FlipX: 0
|
||||||
|
m_FlipY: 0
|
||||||
|
m_DrawMode: 0
|
||||||
|
m_Size: {x: 0.64, y: 0.64}
|
||||||
|
m_AdaptiveModeThreshold: 0.5
|
||||||
|
m_SpriteTileMode: 0
|
||||||
|
m_WasSpriteAssigned: 1
|
||||||
|
m_MaskInteraction: 0
|
||||||
|
m_SpriteSortPoint: 0
|
||||||
|
--- !u!4 &698542427
|
||||||
|
Transform:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 698542424}
|
||||||
|
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
|
||||||
|
m_LocalPosition: {x: 0.76199996, y: -0.48, z: -0.018071042}
|
||||||
|
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||||
|
m_Children: []
|
||||||
|
m_Father: {fileID: 0}
|
||||||
|
m_RootOrder: 2
|
||||||
|
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||||
--- !u!1001 &5841415791122168402
|
--- !u!1001 &5841415791122168402
|
||||||
PrefabInstance:
|
PrefabInstance:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
|
@ -227,12 +337,12 @@ PrefabInstance:
|
||||||
- target: {fileID: 5841415790350674206, guid: dc287deb81f09d8419a5051e1d177e74,
|
- target: {fileID: 5841415790350674206, guid: dc287deb81f09d8419a5051e1d177e74,
|
||||||
type: 3}
|
type: 3}
|
||||||
propertyPath: m_LocalPosition.x
|
propertyPath: m_LocalPosition.x
|
||||||
value: -0.14237249
|
value: 0
|
||||||
objectReference: {fileID: 0}
|
objectReference: {fileID: 0}
|
||||||
- target: {fileID: 5841415790350674206, guid: dc287deb81f09d8419a5051e1d177e74,
|
- target: {fileID: 5841415790350674206, guid: dc287deb81f09d8419a5051e1d177e74,
|
||||||
type: 3}
|
type: 3}
|
||||||
propertyPath: m_LocalPosition.y
|
propertyPath: m_LocalPosition.y
|
||||||
value: -0.5522889
|
value: 0
|
||||||
objectReference: {fileID: 0}
|
objectReference: {fileID: 0}
|
||||||
- target: {fileID: 5841415790350674206, guid: dc287deb81f09d8419a5051e1d177e74,
|
- target: {fileID: 5841415790350674206, guid: dc287deb81f09d8419a5051e1d177e74,
|
||||||
type: 3}
|
type: 3}
|
||||||
|
|
|
@ -6,20 +6,28 @@ public class Tavernkeeper_controller : MonoBehaviour
|
||||||
{
|
{
|
||||||
public float mvt_speed = 5.0f; //Movement speed
|
public float mvt_speed = 5.0f; //Movement speed
|
||||||
|
|
||||||
Rigidbody2D rigidbody2d;
|
|
||||||
|
IDictionary<string, GameObject> hand_container;
|
||||||
|
|
||||||
// Last user inputs
|
// Last user inputs
|
||||||
float horizontal;
|
float horizontal;
|
||||||
float vertical;
|
float vertical;
|
||||||
float hands;
|
float hands;
|
||||||
|
|
||||||
Animator animator;
|
|
||||||
Vector2 lookDirection = new Vector2(1,0);
|
Vector2 lookDirection = new Vector2(1,0);
|
||||||
|
Rigidbody2D rigidbody2d;
|
||||||
|
Animator animator;
|
||||||
|
|
||||||
// Start is called before the first frame update
|
// Start is called before the first frame update
|
||||||
void Start()
|
void Start()
|
||||||
{
|
{
|
||||||
rigidbody2d = GetComponent<Rigidbody2D>();
|
rigidbody2d = GetComponent<Rigidbody2D>();
|
||||||
animator = GetComponent<Animator>();
|
animator = GetComponent<Animator>();
|
||||||
|
|
||||||
|
hand_container = new Dictionary<string, GameObject>(){
|
||||||
|
{"left", null},
|
||||||
|
{"right", null}
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update is called once per frame
|
// Update is called once per frame
|
||||||
|
@ -49,11 +57,13 @@ public class Tavernkeeper_controller : MonoBehaviour
|
||||||
{
|
{
|
||||||
if(hands>0)
|
if(hands>0)
|
||||||
{
|
{
|
||||||
Debug.Log("Left hand");
|
// Debug.Log("Left hand");
|
||||||
|
handAction("left");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Debug.Log("Right hand");
|
// Debug.Log("Right hand");
|
||||||
|
handAction("right");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -68,4 +78,32 @@ public class Tavernkeeper_controller : MonoBehaviour
|
||||||
|
|
||||||
rigidbody2d.MovePosition(position); //Movement processed by the phyisc engine for Collision, etc.
|
rigidbody2d.MovePosition(position); //Movement processed by the phyisc engine for Collision, etc.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void handAction(string hand)
|
||||||
|
{
|
||||||
|
//Empty hand : try grab
|
||||||
|
if(hand_container[hand] is null)
|
||||||
|
{
|
||||||
|
// Test collision of ray from tavernkeeper center at 1.5 unit distance
|
||||||
|
RaycastHit2D hit = Physics2D.Raycast(rigidbody2d.position + Vector2.up * 0.2f, lookDirection, 1.5f);
|
||||||
|
if (hit.collider != null)
|
||||||
|
{
|
||||||
|
// Debug.Log("Raycast has hit the object " + hit.collider.gameObject);
|
||||||
|
GameObject hit_object = hit.collider.gameObject;
|
||||||
|
if (hit_object != null)
|
||||||
|
{
|
||||||
|
hit_object.transform.SetParent(transform);
|
||||||
|
hit_object.transform.localPosition = new Vector2(-0.2f,0.2f);
|
||||||
|
hand_container[hand]=hit_object;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else //Full hand : drop
|
||||||
|
{
|
||||||
|
// Debug.Log("Hand full with "+ hand_container[hand]);
|
||||||
|
hand_container[hand].transform.SetParent(null);
|
||||||
|
hand_container[hand].transform.position = rigidbody2d.position;
|
||||||
|
hand_container[hand]=null;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue