I have a code that allows me to spawn objects using instantiation, I can simply mouse down and I would get the object to follow my cursor and then once I release (mouse up) the object drops and fully spawns along side its properties get activated (e.g. rigidbody).
I’m trying to use 3 sliders and work with the code I have but just can’t figure out how to make it work with instance of an object and can only scale objects that have already spawned, once again I don’t want the all the prefab clones (instances to grow) just the ones that currently being spawned as I click.
Spawner.transform.localScale = new Vector3(x, y, z);
unless I’m not understanding what you’re trying to do? You don’t want to scale the prefab before you instantiate - just instantiate and then scale. It all happens in the same frame so the user won’t know the difference.
I’m not sure sure however it works better, as long as each clone has its unique scaling factors upon slider property changing. but then the original is changing so I’m not sure what effect that has on the clones.
I have a script attached to my camera with a game object variable which I’ve dragged my prefab to it within my inspector.
Also how do I make it work with a slider, can you assist me with this please? where do I put my void before mouse up parameter or after, also do I need to assign a gameobject on my parameter?
public void setobjScaling (){
if (Input.GetKey (KeyCode.P))
Spawner.transform.localScale = new Vector3(10, 10, 10);
}
as a test it didn’t even work
is there anything wrong with this or anything I need to assign?
Also what would be the code to use for the the slider? one last thing where section do I stick this code before the mouse down after? or inside my mouse up if statement? - thanks.
update: got it to work now I just need to work out how to use the slider, many thanks if you could spare some of your time to help me with this.
One last thing kind sir, how do I set a limit to scaling? e.g. I don’t want the x y and z value to go over 5. #- update: got it to work now I just need to work out how to use the slider, many thanks if you could spare some of your time to help me with this.
Thanks a lot friend, also how would I assign the code to the slider? do I need to call for the slider within my code? or call and assign the function within the slider itself in the inspector?