How to spam different bot models ?

General support.
User avatar
MAC
Contributor
Contributor
Posts: 95
Joined: Sun May 27, 2018 7:59 am
Contact:

Nope for now.. my project is busy by reloading all asset ..
But if i find a way whit your coding indication i will share it ..
If someone have it working and share it..
i will share whit you a very big object selection, will make you make a great game in a short time : )
MFPS on HDRP --) https://ka2studio.net/
User avatar
MAC
Contributor
Contributor
Posts: 95
Joined: Sun May 27, 2018 7:59 am
Contact:

killa187 wrote: Thu Jun 25, 2020 5:30 pm
using UnityEngine;
using Photon.Pun;
using Photon.Realtime;
using UnityEditor;
using System.Collections;
using System.Collections.Generic;
using System;
public class LoadOutSwitch : MonoBehaviour
{
// Start is called before the first frame update
public bl_AIShooterAgent[] bots;
public bool h = false;
// Start is called before the first frame update
void Start()
{
int b1 = (int)UnityEngine.Random.Range(0f, bots.Length);
int b2 = (int)UnityEngine.Random.Range(0f, bots.Length);

bl_AIShooterAgent oldBot = bl_GameData.Instance.BotTeam1;
bl_AIShooterAgent oldBot2 = bl_GameData.Instance.BotTeam2;
bl_GameData.Instance.BotTeam1 = bots[b1];
bl_GameData.Instance.BotTeam2 = bots[b2];
}
// Update is called once per frame
void Update()
{

}
}
Hello well, for now i don't get better result.. x)
Its change the models on starting game, load value news in gamedata but its not cycling the models and its using only the first one in the list.

I'll made anothers try later..
MFPS on HDRP --) https://ka2studio.net/
User avatar
MAC
Contributor
Contributor
Posts: 95
Joined: Sun May 27, 2018 7:59 am
Contact:

Well i splited in 2 the script for the 2 teams .
So you can spam differents models for each team and you can use the first for the ffa or dm

I make it working whit the update function .. i know its not the right solution.. but it's working.
so it need to be updated in the start function idk whit a timer or a coroutine..

Team 1 :

Code: Select all

using UnityEngine;
using Photon.Pun;
using Photon.Realtime;
using UnityEditor;
using System.Collections;
using System.Collections.Generic;
using System;
public class LoadOutSwitch : MonoBehaviour
{
    // Start is called before the first frame update
    public bl_AIShooterAgent[] bots;
    public bool h = false;


    // Start is called before the first frame update
    void Start()
    {
        
        int b1 =  (int)UnityEngine.Random.Range(0f, bots.Length);
        bl_AIShooterAgent oldBot = bl_GameData.Instance.BotTeam1;
        bl_GameData.Instance.BotTeam1 = bots[b1];


    }
    // Update is called once per frame
    void Update()
    {

        int b1 = (int)UnityEngine.Random.Range(0f, bots.Length);
        bl_AIShooterAgent oldBot = bl_GameData.Instance.BotTeam1;
        bl_GameData.Instance.BotTeam1 = bots[b1];
    }
}

Team 2 :

Code: Select all

using UnityEngine;
using Photon.Pun;
using Photon.Realtime;
using UnityEditor;
using System.Collections;
using System.Collections.Generic;
using System;
public class LoadOutSwitch1 : MonoBehaviour
{
    // Start is called before the first frame update
    public bl_AIShooterAgent[] bots;
    public bool h = false;


    // Start is called before the first frame update
    void Start()
    {

        int b2 = (int)UnityEngine.Random.Range(0f, bots.Length);
        bl_AIShooterAgent oldBot2 = bl_GameData.Instance.BotTeam2;
        bl_GameData.Instance.BotTeam2 = bots[b2];

    }
    // Update is called once per frame
    void Update()
    {

        int b2 = (int)UnityEngine.Random.Range(0f, bots.Length);
        bl_AIShooterAgent oldBot2 = bl_GameData.Instance.BotTeam2;
        bl_GameData.Instance.BotTeam2 = bots[b2];
    }
}
MFPS on HDRP --) https://ka2studio.net/
User avatar
MAC
Contributor
Contributor
Posts: 95
Joined: Sun May 27, 2018 7:59 am
Contact:

Lovatto wrote: Sat Jan 18, 2020 7:08 am
killa187 wrote: Thu Jun 25, 2020 5:30 pm
Hello,

Well finaly i fixed it..

So 2 script, LoadOutSwitch for team1 and LoadOutSwitch1 for team 2.
It's spawn differents bot model whit a timer fixed to 10 sec.
You can add it on your Spawn prefab or on another:

Team 1 :

Code: Select all

using UnityEngine;
using Photon.Pun;
using Photon.Realtime;
using UnityEditor;
using System.Collections;
using System.Collections.Generic;
using System;

public class LoadOutSwitch : MonoBehaviour
{
    // Start is called before the first frame update
    public bl_AIShooterAgent[] bots;
    public bool h = false;
    public float switchTime = 10f;

    // Start is called before the first frame update
    void Start()
    {

        int b1 = (int)UnityEngine.Random.Range(0f, bots.Length);
        bl_AIShooterAgent oldBot = bl_GameData.Instance.BotTeam1;
        bl_GameData.Instance.BotTeam1 = bots[b1];

    }
    // Update is called once per frame
    void Update()

    {
        {
            switchTime -= Time.deltaTime;
            if (switchTime < 0f)
            {
                
                int b1 = (int)UnityEngine.Random.Range(0f, bots.Length);
                bl_AIShooterAgent oldBot = bl_GameData.Instance.BotTeam1;
                bl_GameData.Instance.BotTeam1 = bots[b1];
                switchTime = 10f;
            }
        }
    }
}
Team 2 :

Code: Select all

using UnityEngine;
using Photon.Pun;
using Photon.Realtime;
using UnityEditor;
using System.Collections;
using System.Collections.Generic;
using System;

public class LoadOutSwitch1 : MonoBehaviour
{
    // Start is called before the first frame update
    public bl_AIShooterAgent[] bots;
    public bool h = false;
    public float switchTime = 10f;

    // Start is called before the first frame update
    void Start()
    {

        int b2 = (int)UnityEngine.Random.Range(0f, bots.Length);
        bl_AIShooterAgent oldBot = bl_GameData.Instance.BotTeam2;
        bl_GameData.Instance.BotTeam2 = bots[b2];

    }
    // Update is called once per frame
    void Update()

    {
        {
            switchTime -= Time.deltaTime;
            if (switchTime < 0f)
            {

                int b2 = (int)UnityEngine.Random.Range(0f, bots.Length);
                bl_AIShooterAgent oldBot = bl_GameData.Instance.BotTeam2;
                bl_GameData.Instance.BotTeam2 = bots[b2];
                switchTime = 10f;
            }
        }
    }
}
Thank to Killa for the base coding : )
MFPS on HDRP --) https://ka2studio.net/
User avatar
killa187
Contributor
Contributor
Posts: 56
Joined: Thu Apr 23, 2020 7:46 pm

MAC wrote: Thu Jul 02, 2020 5:46 am
Lovatto wrote: Sat Jan 18, 2020 7:08 am
killa187 wrote: Thu Jun 25, 2020 5:30 pm
Hello,

Well finaly i fixed it..

So 2 script, LoadOutSwitch for team1 and LoadOutSwitch1 for team 2.
It's spawn differents bot model whit a timer fixed to 10 sec.
You can add it on your Spawn prefab or on another:

Team 1 :

Code: Select all

using UnityEngine;
using Photon.Pun;
using Photon.Realtime;
using UnityEditor;
using System.Collections;
using System.Collections.Generic;
using System;

public class LoadOutSwitch : MonoBehaviour
{
    // Start is called before the first frame update
    public bl_AIShooterAgent[] bots;
    public bool h = false;
    public float switchTime = 10f;

    // Start is called before the first frame update
    void Start()
    {

        int b1 = (int)UnityEngine.Random.Range(0f, bots.Length);
        bl_AIShooterAgent oldBot = bl_GameData.Instance.BotTeam1;
        bl_GameData.Instance.BotTeam1 = bots[b1];

    }
    // Update is called once per frame
    void Update()

    {
        {
            switchTime -= Time.deltaTime;
            if (switchTime < 0f)
            {
                
                int b1 = (int)UnityEngine.Random.Range(0f, bots.Length);
                bl_AIShooterAgent oldBot = bl_GameData.Instance.BotTeam1;
                bl_GameData.Instance.BotTeam1 = bots[b1];
                switchTime = 10f;
            }
        }
    }
}
Team 2 :

Code: Select all

using UnityEngine;
using Photon.Pun;
using Photon.Realtime;
using UnityEditor;
using System.Collections;
using System.Collections.Generic;
using System;

public class LoadOutSwitch1 : MonoBehaviour
{
    // Start is called before the first frame update
    public bl_AIShooterAgent[] bots;
    public bool h = false;
    public float switchTime = 10f;

    // Start is called before the first frame update
    void Start()
    {

        int b2 = (int)UnityEngine.Random.Range(0f, bots.Length);
        bl_AIShooterAgent oldBot = bl_GameData.Instance.BotTeam2;
        bl_GameData.Instance.BotTeam2 = bots[b2];

    }
    // Update is called once per frame
    void Update()

    {
        {
            switchTime -= Time.deltaTime;
            if (switchTime < 0f)
            {

                int b2 = (int)UnityEngine.Random.Range(0f, bots.Length);
                bl_AIShooterAgent oldBot = bl_GameData.Instance.BotTeam2;
                bl_GameData.Instance.BotTeam2 = bots[b2];
                switchTime = 10f;
            }
        }
    }
}
Thank to Killa for the base coding : )
that looks cool i was just about write another like that bit diff but i like that setup i just might use myself :).one the other came from game is on google play store but it crashed in unity big time and so many diff assets to figure out quick the prob so redoing been busy with that. i still got keystore file google play would accept im sure i let them handle keystore if understand might not matter now if lose original but never tried lol so kept that.glad got working and i like its setup so i just might use in the one remaking now
Post Reply