Commit 7b0fdf74 authored by KenzyAshour2's avatar KenzyAshour2

box collider added

spwaner added
parent 9aebf21d
fileFormatVersion: 2
guid: b31d29eab57f8e34f9e336051ad20e87
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!1 &8621037051837905417
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 6487795819855637101}
- component: {fileID: 8551629717659174405}
- component: {fileID: 7177006873302419109}
- component: {fileID: 5504871389098103611}
- component: {fileID: 7826709417781551847}
m_Layer: 0
m_Name: Rock
m_TagString: Rock
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &6487795819855637101
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 8621037051837905417}
serializedVersion: 2
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: -2.86, y: -0.47, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 0}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!212 &8551629717659174405
SpriteRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 8621037051837905417}
m_Enabled: 1
m_CastShadows: 0
m_ReceiveShadows: 0
m_DynamicOccludee: 1
m_StaticShadowCaster: 0
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: 1
m_Sprite: {fileID: -2413806693520163455, guid: a86470a33a6bf42c4b3595704624658b, type: 3}
m_Color: {r: 1, g: 1, b: 1, a: 1}
m_FlipX: 0
m_FlipY: 0
m_DrawMode: 0
m_Size: {x: 1, y: 1}
m_AdaptiveModeThreshold: 0.5
m_SpriteTileMode: 0
m_WasSpriteAssigned: 1
m_MaskInteraction: 0
m_SpriteSortPoint: 0
--- !u!61 &7177006873302419109
BoxCollider2D:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 8621037051837905417}
m_Enabled: 1
m_Density: 1
m_Material: {fileID: 0}
m_IncludeLayers:
serializedVersion: 2
m_Bits: 0
m_ExcludeLayers:
serializedVersion: 2
m_Bits: 0
m_LayerOverridePriority: 0
m_ForceSendLayers:
serializedVersion: 2
m_Bits: 4294967295
m_ForceReceiveLayers:
serializedVersion: 2
m_Bits: 4294967295
m_ContactCaptureLayers:
serializedVersion: 2
m_Bits: 4294967295
m_CallbackLayers:
serializedVersion: 2
m_Bits: 4294967295
m_IsTrigger: 0
m_UsedByEffector: 0
m_UsedByComposite: 0
m_Offset: {x: 0, y: 0}
m_SpriteTilingProperty:
border: {x: 0, y: 0, z: 0, w: 0}
pivot: {x: 0.5, y: 0.5}
oldSize: {x: 1, y: 1}
newSize: {x: 1, y: 1}
adaptiveTilingThreshold: 0.5
drawMode: 0
adaptiveTiling: 0
m_AutoTiling: 0
serializedVersion: 2
m_Size: {x: 1, y: 1}
m_EdgeRadius: 0
--- !u!50 &5504871389098103611
Rigidbody2D:
serializedVersion: 4
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 8621037051837905417}
m_BodyType: 0
m_Simulated: 1
m_UseFullKinematicContacts: 0
m_UseAutoMass: 0
m_Mass: 1
m_LinearDrag: 0
m_AngularDrag: 0.05
m_GravityScale: 0.4
m_Material: {fileID: 0}
m_IncludeLayers:
serializedVersion: 2
m_Bits: 0
m_ExcludeLayers:
serializedVersion: 2
m_Bits: 0
m_Interpolate: 0
m_SleepingMode: 1
m_CollisionDetection: 0
m_Constraints: 0
--- !u!114 &7826709417781551847
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 8621037051837905417}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: a988a7abe4883994ea526b4fb710800b, type: 3}
m_Name:
m_EditorClassIdentifier:
gravityscale: 0.2
fileFormatVersion: 2
guid: 2bf24dcef6578e848b1f39c21a0fb763
PrefabImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
This diff is collapsed.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Basket : MonoBehaviour
{
private int rockCount = 0;
private int maxRocks = 5;
void OntriggerEnter2D(Collider2D other)
{
if (other.gameobject.CompareTag("Rock"))
{
rockCount++;
Destroy(other.gameobject);
if (rockCount >= maxRocks)
{
Debug.Log("Basket is full!"); //etmla
}
}
}
void Full()
{
// Logic when basket is full
}
}
fileFormatVersion: 2
guid: 702589aede7a7294f8700d698d7a2021
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
......@@ -4,12 +4,26 @@ public class DraggableObjects : MonoBehaviour
{
private Vector3 mOffset;
private float mZCoord;
[SerializeField] float gravityscale;
Rigidbody2D rb;
void Start()
{
rb = GetComponent<Rigidbody2D>();
}
void OnMouseDown()
{
rb.gravityScale = 0;
mZCoord = Camera.main.WorldToScreenPoint(gameObject.transform.position).z;
mOffset = gameObject.transform.position - GetMouseAsWorldPoint();
}
void OnMouseUp()
{
rb.gravityScale = gravityscale;
}
void OnMouseDrag()
{
transform.position = GetMouseAsWorldPoint() + mOffset;
......
using UnityEngine;
public class RockSpawner : MonoBehaviour
{
[Header("Spawn")]
public Transform mouthPoint;
public GameObject rockPrefab;
public float spawnInterval = 0.6f;
public int burstCount = 1;
public bool looping = true;
[Header("Launch Force")]
public Vector2 minForce = new Vector2(-1f, 6f);
public Vector2 maxForce = new Vector2(1f, 9f);
public float angularVelocityRange = 200f;
[Header("Physics tweaks")]
public float rockGravityScale = 1.5f;
public float rockMass = 1f;
private void Start()
{
if (looping) InvokeRepeating(nameof(SpawnBurst), 0.2f, spawnInterval);
}
public void SpawnBurst()
{
for (int i = 0; i < burstCount; i++)
{
SpawnRock();
}
}
void SpawnRock()
{
if (rockPrefab == null || mouthPoint == null) return;
GameObject go = Instantiate(rockPrefab, mouthPoint.position, Quaternion.identity);
Rigidbody2D rb = go.GetComponent<Rigidbody2D>();
if (rb == null) rb = go.AddComponent<Rigidbody2D>();
// Apply physics settings
rb.gravityScale = rockGravityScale;
rb.mass = rockMass;
rb.constraints = RigidbodyConstraints2D.None;
// randomize force: x between min and max x, y between min and max y
float fx = Random.Range(minForce.x, maxForce.x);
float fy = Random.Range(minForce.y, maxForce.y);
Vector2 force = new Vector2(fx, fy);
rb.AddForce(force, ForceMode2D.Impulse);
// random angular velocity
rb.angularVelocity = Random.Range(-angularVelocityRange, angularVelocityRange);
// Optional: destroy after some time to clean up
Destroy(go, 10f);
}
}
\ No newline at end of file
fileFormatVersion: 2
guid: 5a4461e77c2c82646a3f1f0c9120e836
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
using UnityEngine;
public class SpawnFromTop : MonoBehaviour
{
[Header("Spawn Settings")]
public GameObject prefab;
public float spawnInterval = 1f;
private Camera cam;
void Start()
{
cam = Camera.main;
InvokeRepeating(nameof(SpawnObject), 0f, spawnInterval);
}
void SpawnObject()
{
// Get top of the screen in world units
Vector3 top = cam.ScreenToWorldPoint(new Vector3(Screen.width / 2f, Screen.height, 10f));
// Random X between left and right screen limits
Vector3 left = cam.ScreenToWorldPoint(new Vector3(0, Screen.height, 10f));
Vector3 right = cam.ScreenToWorldPoint(new Vector3(Screen.width, Screen.height, 10f));
float randomX = Random.Range(left.x, right.x);
Vector3 spawnPos = new Vector3(randomX, top.y, 0f);
Instantiate(prefab, spawnPos, Quaternion.identity);
}
}
\ No newline at end of file
fileFormatVersion: 2
guid: a585ac7febb39d746ad84b5abd428ecf
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
......@@ -3,7 +3,8 @@
--- !u!78 &1
TagManager:
serializedVersion: 2
tags: []
tags:
- Rock
layers:
- Default
- TransparentFX
......
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