28 lines
714 B
C#
28 lines
714 B
C#
![]() |
using System.Collections;
|
||
|
using System.Collections.Generic;
|
||
|
using UnityEngine;
|
||
|
using Sirenix.OdinInspector;
|
||
|
|
||
|
public class DebugHelper : MonoBehaviour
|
||
|
{
|
||
|
[Header("给多大的力")]
|
||
|
public float strength;
|
||
|
|
||
|
void Update()
|
||
|
{
|
||
|
// 按下上方向键给马刚体一个右上角的力
|
||
|
if(Input.GetKeyDown(KeyCode.UpArrow))
|
||
|
{
|
||
|
Debug.Log("Up");
|
||
|
GameObject.Find("马").GetComponent<Rigidbody2D>().AddForce(new Vector2(1,1) * strength,ForceMode2D.Impulse);
|
||
|
}
|
||
|
|
||
|
// 按下R重启场景
|
||
|
if(Input.GetKeyDown(KeyCode.R))
|
||
|
{
|
||
|
Debug.Log("R");
|
||
|
UnityEngine.SceneManagement.SceneManager.LoadScene(0);
|
||
|
}
|
||
|
}
|
||
|
}
|