How do you ‘do something’ to every element in a list except that one index? (C# Beginners Level Question) [closed]

I created a list of 40 buttons, each of these buttons have an ‘int counter’ that counts up incrementally to 5 whenever pressed.

If I hit button 1, the other button’s counter will reset and become 0, but the button I hit can now increase to 2, 3, 4, 5.

How would you loop the list in a way that doesn’t also reset the button being pressed?

Button itself is a class, and I have a ButtonManager that contains List< Button > Buttons

Unity XR: Get boundary world position

I’m trying to create something simular to "Everest VR"’s "Stand on the footprint" system.

The way it works is the game get’s the XR boundary, places a footprints texture in the corner of the play area and rotates the footprints towards the center of the playarea.

Now this isn’t too hard, I’m currently developing on Oculus Quest and I’m using:

using Unity.XR.Oculus;  public GameObject PlayAreaVisual; // A visual reference of what should be the playarea  bool oculusPlayAreaSet = Boundary.GetBoundaryDimensions(Boundary.BoundaryType.PlayArea, out Vector3 dim);  PlayAreaVisual.transform.localScale = new Vector3(dim.x, 0.1f, dim.z); 

to get the size of the playarea. The issue is that if the user resets the camera / "Reset view" by holding the Oculus button, it’s as if the XR system doesn’t understand that the camera has been reset, and uses the camera reset as an offset and doesn’t show the "real world boundaries".

Oculus Quest boundary is offset due to resetting the camera

In the screenshot you can see the Vector3 which is dim from Boundary.GetBoundaryDimensions(Boundary.BoundaryType.PlayArea, out Vector3 dim); This gives the size of the boundary but I still don’t know the correct position

I even tried having two custom play area objects, one on the camera offset, and one on the XR Rig root, but they end up overlapping

Unity inspector

TLDR; Using the Oculus Quest "Reset View" makes Unity "forgot" where the boundry is supposed to be

Question: How do you get the boundary world position / XR rig offset?

Looking to build a game that uses names of Premier League teams – what are the steps required to stay compliant

I am looking to build a game that users would play weekly. In order for the game to make sense, I would have to display the names of the 20 Premier League teams playing on a weekly basis. I will not be using the names of players themselves. The game would require people to pay to contend for their share of a weekly pot of winnings.

The game would be similar to: https://fantasy.espn.com/games/english-premier-league-pickem-2020/make-picks

LWJGL: Not understanding how indices and texturePositions are mapped to vertices

I’ve been following a tutorial on opengl and lwjgl (lwjglgamedev.gitbooks.io/3d-game-development-with-lwjgl) and at some point three different lists are introduced without really explaining how they interact with each other. Can someone explain how it works?

    float[] positions = new float[] {     -0.5f,  0.5f,  0.5f, // V0     -0.5f, -0.5f,  0.5f, // V1      0.5f, -0.5f,  0.5f, // V2      0.5f,  0.5f,  0.5f, // V3     -0.5f,  0.5f, -0.5f, // V4      0.5f,  0.5f, -0.5f, // V5     -0.5f, -0.5f, -0.5f, // V6      0.5f, -0.5f, -0.5f, // V7          // For text coords in top face     -0.5f, 0.5f, -0.5f, // V8: V4 repeated      0.5f, 0.5f, -0.5f, // V9: V5 repeated     -0.5f, 0.5f,  0.5f, // V10: V0 repeated      0.5f, 0.5f,  0.5f, // V11: V3 repeated      // For text coords in right face     0.5f,  0.5f, 0.5f, // V12: V3 repeated     0.5f, -0.5f, 0.5f, // V13: V2 repeated      // For text coords in left face     -0.5f,  0.5f, 0.5f, // V14: V0 repeated     -0.5f, -0.5f, 0.5f, // V15: V1 repeated      // For text coords in bottom face     -0.5f, -0.5f, -0.5f, // V16: V6 repeated      0.5f, -0.5f, -0.5f, // V17: V7 repeated     -0.5f, -0.5f,  0.5f, // V18: V1 repeated      0.5f, -0.5f,  0.5f, // V19: V2 repeated };  float[] texturePos = new float[]{     // Front Face     0.0f, 0.0f,     0.0f, 0.5f,     0.5f, 0.5f,     0.5f, 0.0f,          // Behind Face     0.0f, 0.0f,     0.5f, 0.0f,     0.0f, 0.5f,     0.5f, 0.5f,          // Top Face     0.0f, 0.5f,     0.5f, 0.5f,     0.0f, 1.0f,     0.5f, 1.0f,      // Right Face     0.0f, 0.0f,     0.0f, 0.5f,      // Left Face     0.5f, 0.0f,     0.5f, 0.5f,      // Bottom Face     0.5f, 0.0f,     1.0f, 0.0f,     0.5f, 0.5f,     1.0f, 0.5f, };  int[] indexes = new int[]{     0,  1,  3,  3,  1,  2,  // Front face     8,  10, 11, 9,  8,  11, // Top Face     12, 13, 7,  5,  12, 7,  // Right face     14, 15, 6,  4,  14, 6,  // Left face     16, 18, 19, 17, 16, 19, // Bottom face     4,  6,  7,  5,  4,  7   // Back face }; 

For example, why are there only 2 vertices in the Right and Left face of the texture coords? Also, I’ve noticed that the texture I’m drawing on a cube is insideout on those faces. Could that be the reason?

Thanks in advance.

UE4 – Make AI move up and down?

I have this AI character that flys around on the x and y axis in random directions, but is it possible to make the character move up and down randomly? I tried movement input with a lerp and delay but it couldn’t go up and down. If anybody knows how I can achieve this, please let me know. Thank you! 🙂

Wandering Enemy in unity

Im making a top down shooter in unity. The enemy ai travels straight to the middle before actually wandering when I put in the code. What should I do to fix that? I copy the code in this video:https://www.youtube.com/watch?v=FdNervYWmcE

using System.Collections.Generic; using UnityEngine;  public class EnemyWander : MonoBehaviour {     [SerializeField]     float speed;     [SerializeField]     float range;     [SerializeField]     float maxDis;     Vector2 Waypoint;     // Start is called before the first frame update     void Start()     {         setNewDes();     }      // Update is called once per frame     void Update()     {         transform.position = Vector2.MoveTowards(transform.position, Waypoint, speed * Time.deltaTime);         if(Vector2.Distance(transform.position,Waypoint) < range)         {             setNewDes();         }     }     void setNewDes()     {         Waypoint = new Vector2(Random.Range(-maxDis, maxDis), Random.Range(-maxDis, maxDis));     } }  

How does a PackedScene work when passed in an exported variable

To my beginner understanding, in order to use a scene saved on the drive, one must first use ResourceLoader.load() to load the scene to acquire a PackedScene, then instantiate it using PackedScene.instance() to acquire the Node that can be finally added as a child.

Following this principle, one can easily export a script String variable and use it to set which scene will be loaded by a node – even with convenient hints like this:

export(String, FILE, "*.tscn") var scene_path 

But that’s not fully descriptive in my opinion. I want to select a scene – an only scene – in that exported variable. Looking around the internet, this Godot Q&A post mentions one can export a PackedScene variable like any other to link to another scene. So I immediately thought of this:

export(PackedScene) var new_scene = null 

This looks much cleaner – especially the ability to initialize it to null, as well as having access to methods like can_instance() to catch any accidental false inputs int the editor… however, this looks like there is one important link of the chain I mentioned at the start missing. In the end, I’m still selecting the PackedScene as a path on disk, so when does the load() happen?

Is this a valid and correct use of the export keyword, or could this come back to haunt me later if I overuse it?