Skip to content
View in the app

A better way to browse. Learn more.

LCPDFR.com

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Custom Random Spawnpoints.

Featured Replies

Hi guys, i'm working on a new callout pack and i made like everything but one thing, that i make custom vector3s where the callout will happen.

I have my coordinates, but i can't figure it out. I wanted to make like an array of some sort with all of the vector3s in it but didn't work. I was googleing for a while but i found nothing.

Is there any simple or not simple method that i can do?

So my goal is to get a random vector3 from a before specified list/array for the spawnpoint of the callout. 

Thanks in advance!

SzbZsmbr

            Random rand = new Random();

            Vector3[] spawnpoints = new Vector3[]
            {
                new Vector3(0,0,0),
                new Vector3(0,1,0),
                new Vector3(1,0,1)
            };

            Vector3 spawnpoint = spawnpoints[rand.Next(0, spawnpoints.Length)];

Where spawnpoint becomes a random vecter3 from the array.

Thank you

Would be suggested to have an extension:

public static class EnumerableExtension
{
	public static T PickRandom<T>(this IEnumerable<T> source)
	{
		return source.PickRandom(1).Single();
	}

	public static IEnumerable<T> PickRandom<T>(this IEnumerable<T> source, int count)
	{
		return source.Shuffle().Take(count);
	}

	public static IEnumerable<T> Shuffle<T>(this IEnumerable<T> source)
	{
		return source.OrderBy(x => Guid.NewGuid());
	}
}
      
      //Then you can do something like
      Vector3[] spawnPoints = ...
      Vector3 point = spawnPoints.PickRandom();

 

  • Author
17 hours ago, epicmrjuan said:

            Random rand = new Random();

            Vector3[] spawnpoints = new Vector3[]
            {
                new Vector3(0,0,0),
                new Vector3(0,1,0),
                new Vector3(1,0,1)
            };

            Vector3 spawnpoint = spawnpoints[rand.Next(0, spawnpoints.Length)];

Where spawnpoint becomes a random vecter3 from the array.

Thank you very very very much, i was sooooo close, ridiculous how a simple change in the line makes everything to not work! THANK YOU!

 

 

13 hours ago, OJdoesIt said:

Would be suggested to have an extension:


public static class EnumerableExtension
{
	public static T PickRandom<T>(this IEnumerable<T> source)
	{
		return source.PickRandom(1).Single();
	}

	public static IEnumerable<T> PickRandom<T>(this IEnumerable<T> source, int count)
	{
		return source.Shuffle().Take(count);
	}

	public static IEnumerable<T> Shuffle<T>(this IEnumerable<T> source)
	{
		return source.OrderBy(x => Guid.NewGuid());
	}
}
      
      //Then you can do something like
      Vector3[] spawnPoints = ...
      Vector3 point = spawnPoints.PickRandom();

 

Thanks for yours too, but it seems a bit chinese for me, i will study it.

SzbZsmbr

  • Author
23 hours ago, epicmrjuan said:

            Random rand = new Random();

            Vector3[] spawnpoints = new Vector3[]
            {
                new Vector3(0,0,0),
                new Vector3(0,1,0),
                new Vector3(1,0,1)
            };

            Vector3 spawnpoint = spawnpoints[rand.Next(0, spawnpoints.Length)];

Where spawnpoint becomes a random vecter3 from the array.

And how can i choose the closest one to Game.LocalPlayer.Character? I can't figure it out how can i get each vector from the array and compare them with the position of my character.

Thanks in advance!

SzbZsmbr

6 hours ago, SzbZsmbr said:

Thank you very very very much, i was sooooo close, ridiculous how a simple change in the line makes everything to not work! THANK YOU!

 

 

Thanks for yours too, but it seems a bit chinese for me, i will study it.

The EnumerableExtension class just needs to be added somewhere within your project. You don't need to edit it or anything.

 

43 minutes ago, SzbZsmbr said:

And how can i choose the closest one to Game.LocalPlayer.Character? I can't figure it out how can i get each vector from the array and compare them with the position of my character.

Thanks in advance!

You would add the LINQ namespace via using System.Linq;

Then

Vector3 closestspawnpoint = spawnpoints.OrderBy(x => x.DistanceTo(playerposition)).First();

 

  • Author
1 hour ago, OJdoesIt said:

The EnumerableExtension class just needs to be added somewhere within your project. You don't need to edit it or anything.

 

You would add the LINQ namespace via using System.Linq;

Then


Vector3 closestspawnpoint = spawnpoints.OrderBy(x => x.DistanceTo(playerposition)).First();

 

Thank you so much!

SzbZsmbr

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

Recently Browsing 0

  • No registered users viewing this page.

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.