मुख्य सामग्री पर जाएँ
Skillpedia
सामान्य कोडिंग6.6k · #13826

godot-physics

यह क्या करती है

यह स्किल बताती है कि 2D और 3D गेम में Godot फ़िज़िक्स कैसे काम करती है, जिसमें बॉडी, एरिया और रे शामिल हैं। यह उन गेम बनाने वालों के लिए है जिन्हें चीज़ें सही तरह टकराएँ और प्रतिक्रिया दें।

कब इस्तेमाल करें

  • ✓जब आपको Godot में किरदार, दीवार, गेंद या ट्रिगर के लिए सही बॉडी प्रकार चुनना हो।
  • ✓जब चीज़ें एक-दूसरे के आर-पार जाएँ या गलत चीज़ों से टकराएँ।
  • ✓जब आप जानना चाहें कि कोई चीज़ एरिया में कब आती है, या रे से लाइन जाँचनी हो।

Skill का लिंक

https://github.com/gamedev-skills/awesome-gamedev-agent-skills/blob/main/skills/godot/godot-physics/SKILL.md

इसे कॉपी करके अपने AI (Claude, ChatGPT या Cursor) में पेस्ट करें और निर्देशों का पालन करने को कहें।

कैसे इस्तेमाल करें

सबसे आसान तरीका: मैसेज कॉपी करके अपने AI में पेस्ट करें। वह skill पढ़कर निर्देशों का पालन करेगा।

पेस्ट करने के लिए तैयार मैसेज

इस skill से मेरी मदद करो: https://github.com/gamedev-skills/awesome-gamedev-agent-skills/blob/main/skills/godot/godot-physics/SKILL.md इस लिंक की SKILL.md फ़ाइल पढ़ो और मेरे काम में उसके निर्देशों का पालन करो।
क्या आप चाहते हैं कि आपका AI ऐसी skills खुद ढूँढे?मुफ़्त Skillpedia MCP इंस्टॉल करें: बस एक लाइन, और हर काम से पहले यह 15,000+ skills में खोजता है।1 मिनट में इंस्टॉल करें →

AI से क्या माँगें: उदाहरण

“मेरे Godot गेम में गेंद दीवार के आर-पार निकल जाती है, उसे ठीक से उछालने के लिए क्या करूँ?”

हर हफ़्ते 5 नई skills, 1 मिनट में पढ़ें।

यह कैसे काम करती है

यह बॉडी के प्रकार, कोलिज़न लेयर और मास्क से तय होने वाली टक्कर, ओवरलैप पहचान के काम करने के तरीके और रे जाँच कैसे की जाती है, यह समझाती है।

तकनीकी सामग्री (मूल SKILL.md)

लेखक का मूल टेक्स्ट, अंग्रेज़ी में, सीधे GitHub से।

Godot Physics (4.x, 2D + 3D)

Pick the right physics body, wire up collision layers/masks, detect overlaps, and cast rays. Concepts apply to both 2D and 3D (swap the 2D/3D suffix). Targets Godot 4.7. In 3D, projects created with Godot 4.6 or later run Jolt Physics by default; older projects keep GodotPhysics3D unless someone switched them. 2D always uses Godot's own 2D engine.

When to use

  • Use when choosing between body types, setting collision layers/masks so the right things collide, detecting overlaps (triggers, hurtboxes) with Area, applying forces/impulses to a RigidBody, or casting rays for line-of-sight/ground checks.

When not to use: kinematic character controllers (move_and_slide) → godot-2d-movement; tile collision setup → godot-tilemap; tuning the feel of physics (timestep, mass, jitter) → physics-tuning.

Core workflow

  1. For 3D, check which engine runs before debugging behavior: Project Settings > Physics > 3D > Physics Engine ([physics] 3d/physics_engine="Jolt Physics" in project.godot). Projects created in 4.6+ get Jolt written there by default; with no such line (DEFAULT) the engine is GodotPhysics3D. The API is the same, but joints, ray-cast face indices, kinematic contacts, and collision margins behave differently (see Pitfalls).
  2. Choose the body type:
    • StaticBody — never moves (floors, walls). Collides, no simulation.
    • RigidBody — fully simulated (gravity, forces, bouncing). Don't set its position directly; apply forces/impulses or set linear_velocity.
    • CharacterBody — script-driven kinematic (see godot-2d-movement).
    • Area — detects overlaps and can apply gravity/damping; no solid collision. Every body needs a CollisionShape (or CollisionPolygon) child.
  3. Configure layers and masks. A body is on its layers and scans for its masks. Two bodies interact only if one's layer is in the other's mask. Name layers in Project Settings > Layer Names for clarity.
  4. Detect overlaps with Area signals (body_entered, area_entered).
  5. Drive RigidBodies with forces/impulses, or override _integrate_forces for full control.
  6. Cast rays with a RayCast2D/3D node (polled each frame) or a one-shot space-state query from code.

Patterns

1. Collision layers vs masks (set from code)

# Player is on layer 1, scans layers 2 (walls) and 3 (enemies).
func _ready() -> void:
    set_collision_layer_value(1, true)    # I am on layer 1
    set_collision_mask_value(2, true)     # I collide with things on layer 2
    set_collision_mask_value(3, true)     # ...and layer 3
    # Bit-field forms also exist: collision_layer = 1; collision_mask = 0b110

2. Area2D as a trigger / hurtbox

extends Area2D                            # e.g. a damage zone

func _ready() -> void:
    body_entered.connect(_on_body_entered)
    area_entered.connect(_on_area_entered)

func _on_body_entered(body: Node2D) -> void:
    if body.has_method("take_damage"):
        body.take_damage(10)

func _on_area_entered(area: Area2D) -> void:
    print("Overlapped area: ", area.name)

3. Applying force and impulse to a RigidBody3D

extends RigidBody3D

func push(direction: Vector3) -> void:
    apply_central_impulse(direction * 8.0)     # instantaneous velocity change

func _physics_process(_delta: float) -> void:
    apply_central_force(Vector3.FORWARD * 4.0) # continuous force (per tick)
    # Never set `position` on a RigidBody to move it; use forces/impulses or
    # set linear_velocity. Use freeze=true if you must hold it in place.

4. Raycast two ways

# A) RayCast2D node: enable it, then poll after physics has updated.
@onready var ray: RayCast2D = $RayCast2D    # set target_position in the editor

func _physics_process(_delta: float) -> void:
    if ray.is_colliding():
        var hit := ray.get_collider()
        var point := ray.get_collision_point()

# B) One-shot query from code (no node needed).
func ground_under(global_from: Vector2) -> Dictionary:
    var space := get_world_2d().direct_space_state
    var query := PhysicsRayQueryParameters2D.create(global_from, global_from + Vector2(0, 64))
    query.collision_mask = 1                 # only layer 1
    return space.intersect_ray(query)        # {} if nothing hit, else collider/position/normal

Pitfalls

  • Layer vs mask confusion is the
अक्सर पूछे जाने वाले सवाल

बॉडी और एरिया में क्या अंतर है?

बॉडी दूसरी चीज़ों से भौतिक रूप से टकराती है, जबकि एरिया चीज़ों के ओवरलैप को रोके बिना पहचानता है।

क्या यह किरदार की गति कवर करती है?

पूरी तरह नहीं। किरदार कंट्रोलर की गति एक अलग 2D मूवमेंट स्किल में कवर है।

क्या 3D फ़िज़िक्स इंजन मायने रखता है?

हाँ। स्किल बताती है कि नए 3D प्रोजेक्ट में अलग डिफ़ॉल्ट इंजन हो सकता है, जिससे कुछ व्यवहार बदल सकता है।

जानकारी

लेखक का मूल विवरण

Use Godot 4.7 physics bodies and detection in 2D and 3D: RigidBody, StaticBody, Area, and CharacterBody; collision layers vs masks; contact/overlap signals; and raycasts (RayCast nodes and direct space-state queries). Use when configuring collision layers/masks, detecting overlaps with Area2D/Area3D, applying forces to a RigidBody, or casting rays in a Godot project (.tscn with physics bodies), including 3D projects running Jolt Physics, the default 3D engine for projects created in 4.6+.

repo: gamedev-skills/awesome-gamedev-agent-skills

लोकप्रियता

GitHub स्टार
6.6k
रैंकिंग में स्थान
#13826
लाइसेंस
Apache-2.0
अपडेट की गई
28/10/2026

क्या यह skill काम की है?

0

लॉग इन करें वोट करने के लिए।

कमेंट

  • …

इस repository की और skills

router

6.6k

यह आपके एजेंट को इंजन और काम के प्रकार को पहचानकर किसी अनुरोध के लिए सही गेम डेवलपमेंट स्किल चुनने में मदद करती है।

कोडिंगसामान्य कोडिंग

ai-behavior-trees-utility-ai

6.6k

यह आपके एजेंट को दुश्मनों और किरदारों के लिए बिहेवियर ट्री और यूटिलिटी AI सिस्टम बनाने में मदद करती है, जो प्राथमिकता और स्कोर से कार्रवाई चुनें।

कोडिंगसामान्य कोडिंग

audio-design

6.6k

आपके एजेंट को गेम ऑडियो मिक्सिंग सिखाती है: बस, डेसिबल में वॉल्यूम, डायलॉग में म्यूज़िक धीमा करना और साउंड इफ़ेक्ट की विविधता।

वीडियो और ऑडियोऑडियो और आवाज़

camera-systems

6.6k

यह आपके एजेंट को ऐसे गेम कैमरा बनाने में मदद करती है जो सहजता से पीछा करें, लेवल के भीतर रहें, और 3D में घूम या देख सकें।

कोडिंगसामान्य कोडिंग

मिलती-जुलती skills