Topic was automatically imported from the old Question2Answer platform.
Asked By
thoma
Hi, I made a dead function for my ennemy and now I want to randomize the medkit the ennemy drop when he died but I don’t know how to do it.Thank for helping me
the script:
func kill():
var m = med.instance()
get_parent().add_child(m)
m.position = position
If it’s the position you want to randomise you can use set_translation. Vector3 variables can be used to set the minimum and maximum positions.
export var min : Vector3
export var max : Vector3
m.set_translation(Vector3(rand_range(min.x, max.x), rand_range(min.y, max.y), rand_range(min.z, max.z)))
Thank that will be useful for something else but that not what I wanted to do.
It more like : when the enemy died the player have a chance to get a medic when the enemy died .(Its more something we the instance I think.for example 50% chance to get a medkit or 50% to not get a medic.)
thoma | 2019-06-23 20:09
So something like this?
var randomNumber : float
randomNumber = rand_range(0, 2)
if randomNumber > 1:
#create med