3D Game Programming 2D primitive extra

3D Game Programming 2D primitive extra
Slide Note
Embed
Share

The world of 3D game programming with a focus on object-oriented physics, rigid body colliders, and triggers. Delve into the concepts of game objects, variables, and public classes to create engaging gameplay experiences. Learn about sprite switching, adding scores, and 2D physics settings to enhance your game development skills.

  • Game Development
  • Object-Oriented Programming
  • Physics
  • 3D Games
  • Rigid Bodies

Uploaded on Feb 15, 2025 | 0 Views


Download Presentation

Please find below an Image/Link to download the presentation.

The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author.If you encounter any issues during the download, it is possible that the publisher has removed the file from their server.

You are allowed to download the files provided on this website for personal or commercial use, subject to the condition that they are used lawfully. All files are the property of their respective owners.

The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author.

E N D

Presentation Transcript


  1. 3D Game Programming 2D primitive extra Ming-Te Chi Department of Computer Science, National Chengchi University

  2. Outline Object-Oriented Programming Physics 2D Rigid body Collider and trigger

  3. OBJECT-ORIENTED PROGRAMMING

  4. is-a, has-a Project Scene1 Actor Actor is a GameObject. Actor has a Script. Transform Sprite Renderer Script Box Collider Rigidbody 2D Camera Transform Camera

  5. GameObject Variables activeInHierarchy Is the GameObject active in the scene? activeSelf The local active state of this GameObject. (Read Only) isStatic Editor only API that specifies if a game object is static. layer The layer the game object is in. A layer is in the range [0...31]. scene Scene that the GameObject is part of. tag The tag of this game object. transform The Transform attached to this GameObject. GetComponent<gameManager>()

  6. public public float speed = 20; public Sprite[] sprites; int sprites_index = 0;

  7. Sprite switching if (Input.GetKey(KeyCode.D)) { this.transform.position += new Vector3(speed * Time.deltaTime, 0, 0); this.GetComponent<SpriteRenderer>().sprite = sprites[(++sprites_index)%2]; }

  8. addScore() public class UFOController: MonoBehaviour { void OnTriggerEnter2D(Collider2D other){ GameObject.Find( GameManager ).GetComponent<g ameManager>().addScore(100); } }

  9. PHYSICS 2D

  10. Rigidbody F=ma a=F/m F V= ?? ???????? = ?? = ??2 P

  11. Physics 2D Settings Edit > Project Settings > Physics 2D

  12. Collision action matrix Rigidbody Collider Kinematic Rigidbody Collider Static Trigger Collider Rigidbody Trigger Collider Kinematic Rigidbody Trigger Collider Static Collider Static Collider Rigidbody Collider Kinematic Rigidbody Collider Y Y Y Y Y

  13. Rigidbody Collider Kinematic Rigidbody Collider Static Trigger Collider Rigidbody Trigger Collider Kinematic Rigidbody Trigger Collider Y Static Collider Static Collider Rigidbody Collider Kinematic Rigidbody Collider Static Trigger Collider Rigidbody Trigger Collider Kinematic Rigidbody Trigger Collider Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y

  14. Script-

  15. Awake VS Start Awake (play ) active ( active active awake) Start active (frame) https://gamedevbegin ner.com/start-vs- awake-in-unity/

  16. Update VS FixedUpdate Update ( ) FixedUpdate Edit Project settings Time Fixed Timestep

More Related Content