Hello All,
I've been trying to create an invisible collider that is present on the both client and server side (To prevent fly hack and the positional bouncing from network latency)
Without having to create a transparent skin and instantiate a prefab using that skin, is there a way I can just create a new GameObject and attach a RigidBody + BoxCollider.
Thanks in Advance.
Creation of an Invisible Wall (Both Client and Server Side)
Discussion in 'Rust Development' started by pinkstink, Aug 11, 2018.
-
Hey pink, you're on the right train of thought!
After you create a new game object, attach a component script that makes the collider and sets the position of the transform.
Here is some sample code to get you started.
Code:class ComponentToAttach : MonoBehaviour{ void Setup(things you need, prob just vector3){ gameObject.name = "name"; transform.position = POSITION; gameObject.SetActive(true); } }var newObject = new GameObject().AddComponent<ComponentToAttach>(); newObject.Setup(params);
-
Cheers for that, but unfortunately it doesn't help all that much. This is what I have so far,
Code:InvisibleWall invisibleWall; // Oxide Hook void Loaded() { invisibleWall = new GameObject().AddComponent<InvisibleWall>(); invisibleWall.Setup(new Vector3(50f, 300f, 50f), new Vector3(300f, 1f, 300f)); } // Oxide Hook void Unload() { if (invisibleWall != null) { MonoBehaviour.Destroy(invisibleWall); } } class InvisibleWall : MonoBehaviour { public BoxCollider collider { get; private set; } public Rigidbody rigidBody { get; private set; } public void Setup(Vector3 pos, Vector3 size) { gameObject.name = "Invisible Wall"; gameObject.transform.position = pos; gameObject.SetActive(true); collider = gameObject.AddComponent<BoxCollider>(); rigidBody = gameObject.AddComponent<Rigidbody>(); collider.size = size; rigidBody.constraints = RigidbodyConstraints.FreezeAll; Interface.Oxide.LogInfo($"Invisible Wall Setup {this}"); } }
Below is a gif recording on what is happening on the client side.
Animated GIF - Find & Share on GIPHY
My Goal is to create an invisible collider that provides a surface for player to walk on in the air. -
I don't believe there is a way around that issue ( there is a chance I'm wrong ). Like you said the object only exists on the server so the rubber band effect will always be there.
-
bump bump