using System.Collections; using System.Collections.Generic; using UnityEngine; ///
/// 刚体(通过物理模拟控制位置) ///public class No17_Rigidbody : MonoBehaviour { private Rigidbody2D rb; private float moveSpeed = 1; private float angle = 60; void Start() { rb=GetComponent(); print(rb.position); print(rb.gravityScale + ",该对象受重力影响的程度"); rb.gravityScale = 0; //rb.AddForce(Vector2.right * 10);//持续的力 //rb.AddForce(Vector2.right * 10,ForceMode2D.Impulse);//爆发力 rb.velocity = Vector2.right * moveSpeed; } // Update is called once per frame void Update() { } //物理系统一般存放在此 void FixedUpdate() { //rb.MovePosition(rb.position + Vector2.right * moveSpeed * Time.fixedDeltaTime); rb.MoveRotation(rb.rotation + angle*Time.fixedDeltaTime);//一直旋转着 } }