Hi,
I am quite new to Unity and I would like to have my character choose a waypoint
based from a random number.
I will have four child waypoints to choose from at each parent waypoint.
I was thinking I could have an array which could would hold all the parent waypoints , which in turn hold 4 child waypoints each however im not sure how to implement this.
Im currently using a basic waypoint system below but need to add to it to get the randomness working.
var Waypoint : Transform[];
static var speed : float = 0.5;
private var currentWaypoint : int;
function Update ()
{
if(currentWaypointArray < Waypointscontainer.length)
{
var target : Vector3 = Waypoint[currentWaypoint].position;
var moveDirection : Vector3 = target - transform.position;
var velocity = rigidbody.velocity;
if(moveDirection.magnitude < 0.25 )
{
currentWaypoint++;
}
else
{
velocity = moveDirection.normalized*speed;
}
}
else
{
currentWaypoint = 0;
}
rigidbody.velocity = velocity;
}
Any help would be greatly appreciated.
Thanks
Jacob
I am indeed using the latest version. I've added two images below to show what i did. [116360-conditionalfield.png|116360] [116361-conditionalfieldresukt.png|116361] Is there something that i am doing wrong? I've put your "ConditionalFieldAttribute.cs" in Assets folder and "ConditionalFieldAttributeDrawer.cs" file to Assets/Editor folder. It works with normal fields but it doesn't hide arrays. Thanks for the help!
– qua11q7