Hope you’re doing well !
Sorry about this post, unfortunatelly google is not enought powerfull to help me to the last part
(it’s my first time i use script Unity)
I’ve downloaded an obsolete plug-in for a game and updated it.
It take me all the night cause I’ve to learnt and understand how the engine work.
Unity look like amazing.
The aim was to spawn a prefab (backpack) and put on the back to the player.
var pack = GameManager.server.CreateEntity(".... new_pack.prefab", player.transform.position + new Vector3(0, 0.15F, -0.80F), Quaternion.Euler(0, -90,90));
Replace the good prefab - Done
Put on the back - Done (thx to Vector3)
Use the good rotate - Done (thx to Quaternion)
Use the good size - Fail (maybe with .localScale but it’s not clear for me) the backpack is to big
Many thanks for your time !
Unfortunately it doesn’t work.
I’ve try with other syntaxes and way, but it’s the same.
I think your function is correct but don"t why it doesn’t work into the environement.
Btw i’ve to do without resizing.
public void SpawnEntVisual(BasePlayer player)
{
if (visualEntity != null || !Configuration.ShowOnBack)
return;
var pack = GameManager.server.CreateEntity(".... new_pack.prefab", player.transform.position + new Vector3(0, 0.15F, -0.80F), Quaternion.Euler(0, -90,90));
pack.transform.localScale = Vector3.one * 0.5f;
pack.SetParent(player);
pack.UpdateNetworkGroup();
pack.SendNetworkUpdateImmediate();
pack.Spawn();
Oh thanks, but as mentioned the game is not mine.
I’m working on an obsolete plug-in.
I can change the .cs and reload the plugin in order to see what happen in game.
(i couln’t open the game with the editor)
Thx for your time.
localScale works using the parent; you are setting the localScale before setting the parent,
therefore, you have a scale related to the world
Have fun,
Sylafrs.
Edit: I don’t know the errors that you’ve got.
You are saying that you can’t open the editor, how do you change the script of the game?
if I don’t know that, I can’t help you, the error may be there.
If you have some plugins make sure that they are not missing any dependencies.
If you’re using a DLL make sure all the DLLs it needs are also included.
Many thanks for your reply.
Context: i’m runing a GameServer with the legacy game and more a plug-in who is be able to load some files .cs in order to apply some mods to the game.
I’ve downloaded this .cs but it was totally obsolete.
I’ve made the changes into the .cs and reload the file into the gameserver.
It had take a time to find the good values for the Quaternion.Euler(0, -90,90)) (a lot of … reload…)
For now all is working find, and players enjoy this new feature.
The only issue is the size of the backpack.
By parent, I meant hierarchical parent (see Transform objects as nodes of trees), when the parent is set to null, the object is attached to the world and is the root of its own tree.
It’s not about class legacy
(each GameObject has a Transform component)
When a GameObject has its transform component attached to another gameObject’s transform component, the transform component ‘inherits’ the position, rotation and scale of its parent
If B is attached to A ( <=> B’s parent is A)
If A world position is (0, 0, 1)
If B local position is (1, 0, 0)
If A local scale is (1, 1, 1)
If A local rotation is Quaternion.identity (i.e. no rotation),
Then B world position will be (1, 0, 1)
[edit: was confused between A and B at a moment, corrected it ^^]
The best to understand transform behaviour is to test the transform tools in the editor.
If you can’t open your project, just play a little with unity on a new blank project, it will help you.
You can also watch this video: