I'm making an mod menu for a game called Ravenfield. It's an injectable DLL. I need to modify some things about the player, for example the speed, health, etc etc and for that I need to find the player object which contains all of that. With dnSpy I was able to find the player class which is called "Actor". When I try to find it in public void Start()
by typing Player = FindObjectsOfType<Actor>();
it says "The name "Player" does not exist in the current context.". I've added both UnityEngine.dll and Assembly-CSharp to my refrences.
I haven't slept very well and I'm sort of braindead ATM so if anyone could help me with this, I'd appreciate it very much. :)
Code:
using UnityEngine;
namespace Ravenhack
{
class Main : MonoBehaviour
{
public void Start()
{
Player = FindObjectOfType<Actor>();
}
public void Update()
{
if (Input.GetKeyDown(KeyCode.F4))
{
Player.SetHealth(100f); //FindObjectOfType<Actor>().SetHealth(100f);
}
if (Input.GetKeyDown(KeyCode.Delete))
{
Loader.Unload();
}
}
public void OnGUI()
{
GUI.Label(new Rect(Screen.width / 2, Screen.height / 2, 350f, 550f), "RAVENHACK 1.1");
}
}
}
Neither the class you defined or the class you inherit from ( MonoBehaviour
) has a property or field named Player.
The least you need to make your class work is the line below:
private Actor Player { get; set; }
But you should read more about these topics: C# properties, accessibility and encapsulation
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.