フライパン動き追加
This commit is contained in:
parent
2b8a220714
commit
5e0833d4a9
File diff suppressed because it is too large
Load Diff
|
|
@ -0,0 +1,7 @@
|
|||
fileFormatVersion: 2
|
||||
guid: b6b05cbc51c744ac2ad95a8b229d4ddd
|
||||
PrefabImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -0,0 +1,16 @@
|
|||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
[RequireComponent(typeof(Rigidbody2D))]
|
||||
public class Corn : MonoBehaviour
|
||||
{
|
||||
[SerializeField] private float thrust;
|
||||
private Rigidbody2D rigidbody;
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
rigidbody = GetComponent<Rigidbody2D>();
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 175dce409df2f4d3aa1941a08822e03e
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -0,0 +1,22 @@
|
|||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
namespace MyGame.Scenes.Main
|
||||
{
|
||||
public class Pan : MonoBehaviour
|
||||
{
|
||||
[SerializeField] private float thrust;
|
||||
private PanController controller;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
controller = GetComponentInParent<PanController>();
|
||||
}
|
||||
|
||||
private void OnTriggerStay2D(Collider2D other)
|
||||
{
|
||||
// Debug.Log(controller.Direction);
|
||||
other.attachedRigidbody.AddForce(controller.Direction * thrust, ForceMode2D.Impulse);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 9389c53fc5fd43caaa8a8b9ac0a38cba
|
||||
timeCreated: 1623848067
|
||||
|
|
@ -0,0 +1,69 @@
|
|||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using UnityEngine.EventSystems;
|
||||
|
||||
[RequireComponent(typeof(BoxCollider2D))]
|
||||
public class PanController : MonoBehaviour, IDragHandler, IBeginDragHandler
|
||||
{
|
||||
private Transform cacheTransform;
|
||||
private Vector3 offset;
|
||||
private readonly (float min, float max) borderX = (-4.1f, 4.1f);
|
||||
private readonly (float min, float max) borderY = (-4.1f, 4.1f);
|
||||
// private readonly float futonSpeedMagnificcation = 20f;
|
||||
// public float FutonSpeed { get; private set; }
|
||||
// public bool IsEnter { get; private set; }
|
||||
private Vector2 direction;
|
||||
public Vector2 Direction => direction;
|
||||
private Vector3 prevPos;
|
||||
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
cacheTransform = gameObject.transform;
|
||||
prevPos = cacheTransform.position;
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
// FutonSpeed = 0f;
|
||||
// localPosを比較
|
||||
// IsEnter = cacheTransform.localPosition.y >= clearLocalPosition.y;
|
||||
|
||||
// OnDragが更新されていない場合は方向をゼロにしたいがUpdateでゼロにすると使えなくなるため保留
|
||||
if (cacheTransform.position == prevPos)
|
||||
{
|
||||
direction = Vector2.zero;
|
||||
}
|
||||
prevPos = cacheTransform.position;
|
||||
}
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
// FutonSpeed = 0f;
|
||||
// IsEnter = false;
|
||||
}
|
||||
|
||||
public void OnDrag(PointerEventData eventData)
|
||||
{
|
||||
var currentPoint = Camera.main.ScreenToWorldPoint(new Vector3(eventData.position.x, eventData.position.y,
|
||||
cacheTransform.position.z));
|
||||
direction = eventData.delta.normalized;
|
||||
var pos = currentPoint + offset;
|
||||
// 移動範囲を制限
|
||||
pos.x = Mathf.Clamp(pos.x, borderX.min, borderX.max);
|
||||
pos.y = Mathf.Clamp(pos.y, borderY.min, borderY.max);
|
||||
// FutonSpeed = (pos - cacheTransform.position).magnitude * futonSpeedMagnificcation;
|
||||
cacheTransform.position = pos;
|
||||
}
|
||||
|
||||
public void OnBeginDrag(PointerEventData eventData)
|
||||
{
|
||||
// ドラッグ開始時のobjectのpositionからのズレを記憶
|
||||
offset = cacheTransform.position - Camera.main.ScreenToWorldPoint(new Vector3(eventData.position.x, eventData.position.y,
|
||||
cacheTransform.position.z));
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 722195db1b0214a7ab110e4cf4c2a7ce
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!62 &6200000
|
||||
PhysicsMaterial2D:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name: corn
|
||||
friction: 0
|
||||
bounciness: 0.4
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 1e68e56cd6ac4484ba25eb760e0d3057
|
||||
NativeFormatImporter:
|
||||
externalObjects: {}
|
||||
mainObjectFileID: 6200000
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -0,0 +1,136 @@
|
|||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!1 &1324329073609281157
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 1324329073609281160}
|
||||
- component: {fileID: 1324329073609281163}
|
||||
- component: {fileID: 1324329073609281162}
|
||||
- component: {fileID: 1324329073609281161}
|
||||
- component: {fileID: 5686223397932607609}
|
||||
m_Layer: 0
|
||||
m_Name: corn
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!4 &1324329073609281160
|
||||
Transform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1324329073609281157}
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalPosition: {x: 0.1, y: -0.05, z: -8.493037}
|
||||
m_LocalScale: {x: 3.8039, y: 3.8039, z: 3.8039}
|
||||
m_Children: []
|
||||
m_Father: {fileID: 0}
|
||||
m_RootOrder: 0
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!212 &1324329073609281163
|
||||
SpriteRenderer:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1324329073609281157}
|
||||
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_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: 10911, guid: 0000000000000000f000000000000000, type: 0}
|
||||
m_Color: {r: 1, g: 1, b: 1, a: 1}
|
||||
m_FlipX: 0
|
||||
m_FlipY: 0
|
||||
m_DrawMode: 0
|
||||
m_Size: {x: 0.16, y: 0.16}
|
||||
m_AdaptiveModeThreshold: 0.5
|
||||
m_SpriteTileMode: 0
|
||||
m_WasSpriteAssigned: 1
|
||||
m_MaskInteraction: 0
|
||||
m_SpriteSortPoint: 0
|
||||
--- !u!58 &1324329073609281162
|
||||
CircleCollider2D:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1324329073609281157}
|
||||
m_Enabled: 1
|
||||
m_Density: 1
|
||||
m_Material: {fileID: 0}
|
||||
m_IsTrigger: 0
|
||||
m_UsedByEffector: 0
|
||||
m_UsedByComposite: 0
|
||||
m_Offset: {x: 0, y: 0}
|
||||
serializedVersion: 2
|
||||
m_Radius: 0.07
|
||||
--- !u!50 &1324329073609281161
|
||||
Rigidbody2D:
|
||||
serializedVersion: 4
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1324329073609281157}
|
||||
m_BodyType: 0
|
||||
m_Simulated: 1
|
||||
m_UseFullKinematicContacts: 0
|
||||
m_UseAutoMass: 0
|
||||
m_Mass: 1
|
||||
m_LinearDrag: 0.1
|
||||
m_AngularDrag: 0.05
|
||||
m_GravityScale: 0
|
||||
m_Material: {fileID: 6200000, guid: 1e68e56cd6ac4484ba25eb760e0d3057, type: 2}
|
||||
m_Interpolate: 0
|
||||
m_SleepingMode: 1
|
||||
m_CollisionDetection: 1
|
||||
m_Constraints: 0
|
||||
--- !u!114 &5686223397932607609
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1324329073609281157}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 175dce409df2f4d3aa1941a08822e03e, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
thrust: 0
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 2b790fd908bd14de4a601c21374fb55b
|
||||
PrefabImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Loading…
Reference in New Issue