mirror of
https://github.com/GTA-ASM/SanAndreasUnity
synced 2024-11-23 20:43:04 +00:00
47 lines
1,004 B
C#
47 lines
1,004 B
C#
|
using SanAndreasUnity.Behaviours;
|
|||
|
using UnityEngine;
|
|||
|
|
|||
|
public class CharacterModelChanger : MonoBehaviour
|
|||
|
{
|
|||
|
public KeyCode actionKey = KeyCode.P;
|
|||
|
|
|||
|
// Use this for initialization
|
|||
|
private void Start()
|
|||
|
{
|
|||
|
}
|
|||
|
|
|||
|
// Update is called once per frame
|
|||
|
private void Update()
|
|||
|
{
|
|||
|
if (Input.GetKeyDown(actionKey))
|
|||
|
{
|
|||
|
ChangePedestrianModel();
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
public static void ChangePedestrianModel()
|
|||
|
{
|
|||
|
if (Ped.Instance != null)
|
|||
|
{
|
|||
|
ChangePedestrianModel(Ped.Instance.PlayerModel, -1);
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
public static void ChangePedestrianModel(PedModel ped, int newModelId)
|
|||
|
{
|
|||
|
|
|||
|
if (-1 == newModelId)
|
|||
|
newModelId = Ped.RandomPedId;
|
|||
|
|
|||
|
// Retry with another random model if this one doesn't work
|
|||
|
try
|
|||
|
{
|
|||
|
ped.Load(newModelId);
|
|||
|
}
|
|||
|
catch (System.NullReferenceException ex)
|
|||
|
{
|
|||
|
Debug.LogException (ex);
|
|||
|
ChangePedestrianModel(ped, -1);
|
|||
|
}
|
|||
|
}
|
|||
|
}
|