texts: Good techniques for syncing gameplay actions to specific animation timings?

texts:
So I've come across an issue in the game I'm working on, but it seems to be a pretty fundamental thing that probably comes up in a lot of games.

My game requires that some gameplay function occurs at a very specific point in time during a character animation. And so, as the title says, I'm wondering what are some good techniques and fundamental strategies for syncing gameplay-related events/functions/actions to specific points in a character's animation.

Here are some simple examples of what I'm talking about in various types of games:

Your character reloads their gun in a shooter. Your character plays his/her 'reload' animation, but it's important that the function that sets the currentAmmo variable is only called at the exact moment after the magazine is swapped and the gun is cocked. This might be some point in the middle of the reload animation.
In a turn-based RPG your characters stand in a line facing a line of enemies. When commanded to attack, one of your characters runs/jumps up to one of the enemies and slashes their giant sword before running/jumping back to their standing place. You want to make sure that the enemy is damaged at the exact moment that the slashing animation is played - some point between running up and running back.
In a stealth game, your character can sneak up and interact with computers and buttons in the world. Maybe there is a button that turns off the power supply to the lights of the outpost that you're infiltrating. When the action button is pressed, your character reaches out and pushes the button and then returns to their idle stance. You want the lights to turn off at the exact point in the 'push_button' animation when the button is pushed in.

Admittedly, my particular case is most like the second example, in which I have created an animation where my turn-based character lunges forward during an attack and I want the damage to be applied at the exact moment that the animation seems to be making contact. Because my game using a turn-based system (imagine something like Final Fantasy or Fire Emblem) I want the damage/healing/magic/etc. to be applied at the correct time during each character animation even though I'm not actually using collision/hitboxes.

I should mention that I'm making my game in a popular game engine, and that right now I'm handling this by using their animation events or notifies to achieve something close to the desired results - my character performs a certain command and triggers a command-specific animation (i.e.: 'attack_command') and the animation assets for each one of my commands must include an animation event/notify 'callback' into my characters ExecuteCommand function. In other words - the character tells the attack animation to play, and then the attack animation emits an event/notify callback into the character at the exact moment during the animation when the damage should be dealt.

Honestly, this works for now, but it just feels wrong - like I'm missing some part of the bigger picture here! Part of the reason that this method feels wrong is that it couples the game logic with the animation assets; if my animation asset forgets to include an ExecuteCommand() event/callback, the command wont execute properly and extra code is needed to check if a command animation finished without executing the command. It's messy and it means that my gameplay has a strange dependency on its assets. Of course I want the damage to occur at a specific point during my attack animation, but I feel really weird about calling gameplay code inside animation assets..

So what am I overlooking here? What are some good general techniques for handling these types of situations in which you want certain important gameplay actions to occur at specific times during animations?

Edit: To clarify, this isn't an engine-specific question nor am I looking for engine-specific designs/techniques. I'm interested in general animation/gameplay synchronization techniques that one might use in your game projects regardless of technologies used.


texts: How would a turn based RPG game store move information in a reusable way?

texts:
Suppose I create a turn based RPG in the veins of Pokémon, with a lot of moves and abilities, that would have elements of hand made code, in cases for special effects after a successful attack or status effect, for example, a status buff every turn, or an automatic attack every turn (think rollout or outrage from Pokémon).
def move_name():
    do_primary_effect()//damage, status effect
    do_secondary_effect()//on hit effects, side-effects,
    //delayed buffs/debuffs, setting next move, i.e. rollout, etc.
    set_flags()//flags like invulnerability from moves like dig, fly, etc.

Now suppose I wanted to make this game open source and allowed people to make their own builds/rebuilds or online versions, where they might use a different language. How can I program my moves/abilities in such a way that it can be interpreted by any compiler, regardless of language, so that there is no re-coding moves for different languages?
tldr; how would I go about a format for moves/abilities such that it is compiler independent(might be the wrong word, but means can be read and translated). Now I'm not asking for a direct answer, though those are greatly appreciated, I'm talking mostly about how such a format would look like, so real life examples for existing videogames are greatly appreciated. I've heard my friend say that Pokémon does this  with a data structure, so data structures are also appreciated.


texts: What file formats and conventions should I support to make my game engine artist-friendly?

texts:
I'm writing a game engine, and I want to know what I should do to make it more artist-friendly. I don't want to be too limiting in terms of what file formats I support, etc.

Are there specific formats artists like to model in, or does it not matter, because the 3D modeler abstracts the data storage away?

Is it okay if I don't support per-vertex coloration in my game engine? If I have to store a diffuse, specular, ambient, and emissive color value for each vertex, it doubles the size of the vertices, in the buffer. Is it reasonable to ask artists to do all these things in the textures or maps?


texts:
I am writing an MD5 3D model loader to display animated models. The vertices and texcoords load in correctly, but the lighting is supposed to be smooth. I calculate per-vertex normals by looping through all triangles, finding the triangle normal, and then adding that to each of the triangle's vertices' normal (follow?). Then, I normalize all the normals. This should work, but md5 declares each vertex with a texcoord, meaning that if I have a single vertex that has different texcoords for each of the faces it's attached to, it declares multiple vertices at the same position. Each of these will end up with its own normal, resulting in flat shading. Should I somehow merge duplicate vertices, or export the model differently, or do something fancy that I haven't thought of?

Thanks!


texts: Godot speed up mobile HTML5 Export GLES2 load time

texts:
I got a small Godot project that should be played on mobile devices, however the load time of a GLES2/ HTML5 export project of Godot takes 20+ seconds to load from the server.

To decrease the load time I already tried to decrease the pack size (500kb), but this didn't make a difference. From the project and export settings I couldn't find any option that would decrease the load time either.

Are there other ways to decrease the load time of a Godot GLES2/ HTML5 project?

I can't share the project itself but if I need to display certain settings or need to add more information to make the problem clearer please let me know. =)


texts: how do I set an int to the scroll wheel data in unity

texts:
i need to set an int to data from the scroll wheel so I can have the script use this int to display an item attached to a number from that int. i'm using c#

i set up my scroll wheel input, what am i doing wrong?

here is the script;

  counter = Mathf.RoundToInt(Input.GetAxis("ScrollWheel"));

    Items.text = counter.ToString();


texts: Why the break point is not working with the unity3d editor?

texts:
The visual studio version is : 16.8.3 Visual studio community 2019
The editor version is : 2019.4.15f1 personal
On other project I have opened it's working fine. It also worked fine on this project but then something went wrong now not sure why the break point/s are not working with this project !
In the editor I did double click on a script attached to gameobject and it opened the visual studio then I clicked on the left side to add a break point and did Attach to Unity but the break point on the left is broken with yellow warning.

I tried to close and re open both visual studio and the editor.
In the editor I did : Edit > Preferences > External Tools and this is the settings :

I also clicked on the Regenerate project files.
But nothing worked so far.


texts: Position of XNA.Rectangle is changing the position a spritre is rendered to?

texts:
I'm having this weird problem where the position ocmponent of a rectangle of the XNA type is offsetting the position the sprite is rendered to as well.

I guess a broader question I'm trying to have answered is: how can I make 4 integer values: top, left, bottom, right (in texture space) the equivalent of an XNA rectangle?


texts: Rendering an explosion in 3D Studio Max to a spritesheet?

texts:
I'd like to render a 3D explosion in 3DS Max but into a sprite sheet. My main problem is that I need to use alpha values instead of the viewport background (which is usually black).

Any ideas how I could do this?


texts: Player rotation issues (Player returns to default forward rotation after releasing keys)

texts:
So basically what is happening is that my player rotates and faces the direction that he is currently being steered toward (which is wonderful). But after I release, let's say the A key, meaning he is currently facing and moving to the left, he goes back to facing forward after the key is released.

Here is my code:

public class PlayerMovement : MonoBehaviour {
public bool isGrounded;
private float distToGround;
private Vector3 v;
private Vector3 h;
public float speed;

Rigidbody rb;
Collider col;

void Start() {
    rb = GetComponent<Rigidbody>();
    col = GetComponent<Collider>();
    distToGround = col.bounds.extents.y;
}

void Update() {
    if (Physics.Raycast (transform.position, -Vector3.up, distToGround + 0.1f)) isGrounded = true; else isGrounded = false;
    if (isGrounded) {
        v = new Vector3(0, 0, Input.GetAxis("Vertical")) * speed;
        h = new Vector3(Input.GetAxis("Horizontal"), 0, 0) * speed;
        rb.MovePosition(rb.position + v * Time.deltaTime);
        rb.MovePosition(rb.position + h * Time.deltaTime);

//This deals with all the rotation
        Vector3 direction = new Vector3( Input.GetAxis ("Horizontal"), 0, Input.GetAxis ("Vertical") );
        Quaternion rotation = Quaternion.LookRotation(direction, Vector3.up);
        transform.rotation = rotation;
    }
  }
}

I obviously know that the reason this is happening is because the rotation is being set to the axis currently being pressed, so when I release any key, the rotation goes back to the original position. I just can't quite figure out how to fix it...


texts: OpenGL: What are the adoption rates of the various versions (And what's a reasonable version to use)

texts:
This question is looking for updated answers for this question, which was made 1.5 years ago - as well as seeking more information.

Given that OpenGL 3.0 was released just over 5 years ago, what kinds of numbers are reasonable to expect for casual (To moderator) gamers, who have video cards that support OpenGL 3.0?

I think it's clear that a "modern gamer" would have a video card that supports OpenGL 3.0, and it's reasonable to assume that people who only use their computers for word processing and internet usage wouldn't... But what about in between? Is there data, either implicit through game popularity, or explicit from data sources like Steam (Which only tracks DirectX, sadly), that would give a decent idea of OpenGL adoption rates?

The reason why the Steam hardware survey isn't ideal for this, is because of the fact it groups hardcore gamers (And a lot of them) in with everyone else, not to mention the lack of OpenGL data - which can't always be inferred from DirectX support due to Microsoft requiring newer versions of Windows for newer versions of DirectX.


texts: How to loop through objects in class (XNA)?

texts:
In my game I have an Enemy class, and in that I have a constructor which I use to make Enemy objects.

How do I add all Enemy objects to a list or loop through all of them using a foreach loop?

I have tried various variations of this:

foreach(object E in Enemy){
        //Do collision detection, set AIs next move, etc.
}

However, it always rejects the second part of the foreach loop, saying that Enemy is a type but is used as a variable.


texts: Playing a simple camera animation with Animator

texts:
I haven't worked with the animation system in Unity before and am getting overwhelmed trying to figure out how to start playback of a simple animation. Yes, this is a "stupid question", but I've spent more than an hour researching this and can't find an answer on how to do something this simple:

I've created an animation called CameraZoom for the scene's camera. The CameraZoom animation is supposed to play when a specific event occurs, so I want to trigger it from script. I've created the animation on the camera, it has the Animator component attached to it, and by default the animation plays as soon as the scene starts. I can stop the animation from code, but when I try to start it, nothing happens. Here's my code:

private Animator myAnimation;
void Start () {
    myAnimation = gameObject.GetComponent<Animator>();
    myAnimation.Stop();
}
public void ZoomOut() {
    Debug.Log("Zoom out!");
    myAnimation.Play("CameraZoom");
}

This script successfully stops the animation when the scene starts, but when I call ZoomOut, the animation doesn't play.

Here are the states:

It may be I'm not understanding how to utilize the state machine and I'm trying to play the animation incorrectly. Tutorials I can find on the Animator are either too vague or discuss other features such as triggers and parameters that I don't know how to apply to such a simple task.

I know I could whip up a Coroutine to zoom the camera out in about 30 seconds, but I'm trying to learn how to utilize the Animator for basic keyframe animations.


texts: approach for the system that record player actions and imitate it

texts:
I am trying to implement some kind of system, that would allow AI to imitate player's action at certain points in similar cases. Case example

Player (hp: 10, mp: 5) used skill [BasicAttack] when in battle

When I set for a bot parameters like hp: 10, mp: 5 and state attack it should use BasicAttack skill because in same case player used that action. (I'd like to have ability to define similar cases like when hp: 11, mp: 6 then bot use BasicAttack too because it is similar to hp: 10, mp: 5 case but whatever)

The question is that what are the basic approaches for such cases? Leaving aside snapshotting of player's state, how can such system be implemented?

So far I have two ideas.
My ideas are

1. order player parameters by priority and states and create tree where every node would be
corresponding parameter value. For example node with name [hp] and value [10] will have a
child note [mp] with value [5] thus I can create required paths to actions

2. I have event log with recorded player events. It keeps its record ordered. I iterate over
it and using pattern matching I compare player parameters and retrieve corresponding player
action

The first approach seems much faster though.

But I'd like to know if there already exist approaches for such systems, in order not to reinvent the wheel as I used to do. Are any?


texts: How can I create a parabola that does not use negative X coordinates

texts:
I am currently devloping my first javascript program ever which is a table tennis game.
I am trying to create trajectory for the ball to follow when hit - just a very basic parabola. However im not very good at math, and I have no idea how to do this!

I want to have the parabola start wherever the ball was hit. The X position will be either 100 or 110, since that is the only two positions where it is possible to hit the ball. And the Y position will completely vary.
So I need to create a parabola that - if your looking at a 2D table - starts from the right side of the net and ends up on the right side, as if you did an under arm hit.
I have no ides how to do this since there will be no minus positions!
- Maybe I should have two arcs one coming up and the other one coming down? I also have no idea what equation would make an trajectory in the shape of an arc.


texts: Can I "Pre-rotate" VBOs while loading them in LWJGL?

texts:
It is possible to flip VBOs horizontally and vertically by swapping around destination coordinates.

Is it possible to rotate an image by any angle, such as 45 degrees, using different destination coordinates when loading up a VBO?

I realise that rotating present VBOs can easily be done using a matrix uniform in your vertex shader, but I'm asking about pre-loaded (VBOs) rotations; the VBO that you load being permanently rotated by X degrees.

I am not looking for code but a conceptual method (or an explanation of why this isn't possible).


texts:
What is the procedure to convert 2d path to 3d one. Maybe it's a silly question, but for example:

Let's assume that I have a path from point A to point B. And I have all X and Y coordinates of that path. Is it possible to convert that to a 3d path, so for example to animate a car driving along that path but in 3D.


texts: How do I use depth testing and texture transparency together in my 2.5D world?

texts:
Note: I've already found an answer (which I will post after this question) - I was just wondering if I was doing it right, or if there is a better way.

I'm making a "2.5D" isometric game using OpenGL ES (JOGL). By "2.5D", I mean that the world is 3D, but it is rendered using 2D isometric tiles.

The original problem I had to solve was that my textures had to be rendered in order (from back to front), so that the tiles overlapped properly to create the proper effect. After some reading, I quickly realised that this is the "old hat" 2D approach. This became difficult to do efficiently, since the 3D world can be modified by the player (so stuff can appear anywhere in 3D space) - so it seemed logical that I take advantage of the depth buffer. This meant that I didn't have to worry about rendering stuff in the correct order.

However, I faced a problem. If you use GL_DEPTH_TEST and GL_BLEND together, it creates an effect where objects are blended with the background before they are "sorted" by z order (meaning that you get a weird kind of overlap where the transparency should be).

Here's some pseudo code that should illustrate the problem (incidentally, I'm using libgdx for Android).

create() {
    // ...
    // some other code here
    // ...

    Gdx.gl.glEnable(GL10.GL_DEPTH_TEST);
    Gdx.gl.glEnable(GL10.GL_BLEND);
}

render() {
    Gdx.gl.glClear(GL10.GL_COLOR_BUFFER_BIT | GL10.GL_DEPTH_BUFFER_BIT);
    Gdx.gl.glBlendFunc(GL10.GL_SRC_ALPHA, GL10.GL_ONE_MINUS_SRC_ALPHA);

    // ...
    // bind texture and create vertices
    // ...
}

So the question is: How do I solve the transparency overlap problem?


texts: camera relative movement with GL.Translate

texts:
I'm using the OpenTK library, an OpenGL library, for C#. I'm trying to do camera-relative movement and though I'd use GL.Translate for moving and glRotate for rotation. I've not declared any vectors and every tutorial uses those, how do I do that?
Do I need to limit the user's resolution and just use if statements to check it and move, or something else?
I don't want to declare and use variables like yaw, pitch etc, I just want to directly calculate rotation and apply to movement.
I'm using an old version of OpenGL since my game should be able to run on old GPUs.


texts: How to show a popup with text when a game object is selected?

texts:
We're building an FPS game where you walk around a 3D environment and walk up to objects, click, and then a GUI message pops up.

Basically, I've got a character, walking around in 3D space, and is using a raycast to interact with things. However, I can't figure out how to hook on a UI pop up.

I'm writing in C# because that's what the original tutorial is in. I tried checking out tutorials on how to make a pause menu appear (thinking I could just hook a pause pop up to the raycast clicking action) but all the tutorials are in JS or were written prior to Unity 4.6 UI manager implementation.

So any clue on how to do this?


texts: How to make a smooth circuit path in Universal tween engine?

texts:
I tried to make a circuit by starting at point A, with waypoints B and C and final target at A again, and infinite repeats. What happens is that the path from A to B, B to C is smoothed, but path C to A ends with a "sharp" edge

Is there any way to make it totally smooth?


texts: How to tilt an object(2D) after collision and the rotate continuously

texts:
I am having trouble rotating and object after collision. The object only transforms to the given angle of rotation once and stops. I would like to achieve in a way that after it has collided with the player object it rotates continuously till its killed after exiting the screen. The OnCollisionEnter2D(Collision2D collision) can't achieve this.

How can I achieve it using the FixedUpdate function?

Here is the code:

namespace Assets.scripts
{
    public class Barmovementscript : MonoBehaviour
    {
        public float Tilt;

        private void FixedUpdate()
        {
        }

        // upon collision the object rotates in a clockwise direction.
        void OnCollisionEnter2D(Collision2D collision)
        {
            if (collision.collider.tag == "Player")
            {
                Tilt += Time.deltaTime * -10;
                gameObject.transform.rotation = Quaternion.Euler(0, 0, Tilt);
            }
        }
    }
}


texts:
Possible Duplicate:
  learning Direct3D 9, 10 or 11 ?

I have just started game dev and was wondering should I use DX11 or version 10?

I know AMD/nVidia now have DX11 cards but there are not many games using them now.

So should I wait untill they are mainstearm?


texts: Unity can't recognize class and namespace, how can I fix it?

texts:
I just updated Unity to 5.4 today, though as I saw, this problem was present in previous versions too.

So the error message is :

  The type or namespace name 'FirstPersonController' could not be found (are you missing a using directive or an assembly reference?)

This happens when I try to reference the FPSController prefab's FirstPersonController.cs (obviously I'm talking about the one from StandardAssets/Characters).

Yes, I did try including

using *UnityStandardAssets.Characters.FirstPerson*

in my script, but no, it did not work. Doesn't even recognize is as a valid namespace.

The same happens when I try the other way: when I try referencing my script inside the FirstPersonController.cs. It just doesn't recognize it as valid.

Anybody has any idea how to solve it?


texts:
I read here a spectacular story of someone (scrappily) fixing some things in a game's source code, making it load 4 times faster!
How did the developer get the source code in the first place? Is there a common pattern to getting game source code?
Link to the GitHub repository talked about in the article: https://github.com/tostercx/GTAO_Booster_PoC


texts: How to move a static Body in Farseer 3.2 using touchpad

texts:
I'm developing a 2D game for windows phone using Xna and Farseer library. For now I have two objects/bodies. One is falling from the top and the other one which is static is at the button of the screen and is supposed to be used to catch the object that is falling.

I need to move the static body at the button using mobile phones touch screen only on X axis.

Here is the sample code that I wrote for using the touch pad, note that "tray" is the static body.

private void UpdatePlayer(GameTime gameTime)
    {
        // Windows Phone Controls
        while (TouchPanel.IsGestureAvailable)
        {
            GestureSample gesture = TouchPanel.ReadGesture();
            if (gesture.GestureType == GestureType.FreeDrag)
            {
                tray.Position.X += gesture.Delta.X;
            }
        }

        // Make sure that the player does not go out of bounds
        tray.Position.X = MathHelper.Clamp(tray.Position.X, 0, GraphicsDevice.Viewport.Width - trayTexture.Width);
        tray.Position.Y = MathHelper.Clamp(tray.Position.Y, 0, GraphicsDevice.Viewport.Height - trayTexture.Height);
    }

and this is the initialization of this Body

//Create Floor (tray)
        tray = BodyFactory.CreateRectangle(MyWorld, ConvertUnits.ToSimUnits(143), ConvertUnits.ToSimUnits(12), 10);
        tray.Restitution = 0.2f;        //Bounceability
        tray.Friction = 0.1f;           //Friction
        tray.IsStatic = true;         //Static objects wont move when hit by other objects

        tray.Position = new Vector2(((int)ConvertUnits.ToSimUnits(playerPosition).X),
            ((int)ConvertUnits.ToSimUnits(playerPosition).Y)); //set the position of tray

But the problem is I cannot modify the return value of tray.Position because it's not a variable.

So how can I do it?


texts:
I have a 3d scene that contains an infinite plane that is NOT parallel to the camera (so every screen coordinate corresponds to a point on this plane- in other words, there are no possible invalid clicks/touches).

I have all the information you'd expect to work with: camera pos, dir, fov, aspect ratio, the 3d points defining the plane (either as a triangle, or as a normal + distance), the view/projection matrices that project it onto the screen, etc...

I haven't found anything online that answers this in a straightforward way. Please no "use this or that library". Also, if you're going to say "invert the matrix", please give a way to go about doing that (I don't think the matrix is easily/possibly invertable, as the "project to 2d" process involves the divide-by-w step, rendering the final translation between 3d to 2d non-affine).


texts: Can't get reliable collision detection/response in Monogame

texts:
So, I currently have a Rectangle that updates with player position, and is the size of the sprite. I'm using Tiled as my tile editor, and have an Object layer called "collision" which I loop over when loading the map, and store each object as a Rectangle in a list. Then in my Update I check if the player is colliding with any of those rectangles (via looping over the list) with Rectangle.Intersects(Rectangle). And if a collision is detected, I handle it with this function:

private static void HandleCollision()
{
    if (_currentLevel.IsCollisionTile())
    {
        float deltaLeft = Math.Abs((Player.Instance.Position.X + Player.Instance.PlayerCollider.Width) - (_currentLevel.collidingRectangle.X));
        float deltaRight = Math.Abs((Player.Instance.Position.X) + (_currentLevel.collidingRectangle.X + _currentLevel.collidingRectangle.Width));
        float deltaUp = Math.Abs((Player.Instance.Position.Y + Player.Instance.PlayerCollider.Height) - (_currentLevel.collidingRectangle.Y));
        float deltaDown = Math.Abs((Player.Instance.Position.Y) - (_currentLevel.collidingRectangle.Y + _currentLevel.collidingRectangle.Height));

        if (deltaLeft < deltaRight && deltaLeft < deltaUp && deltaLeft < deltaDown)
        {
            Player.Instance.Position.X -= deltaLeft;
        }
        else if (deltaRight < deltaLeft && deltaRight < deltaUp && deltaRight < deltaDown)
        {
            Player.Instance.Position.X += deltaRight;
        }
        else if (deltaUp < deltaLeft && deltaUp < deltaRight && deltaUp < deltaDown)
        {
            Player.Instance.Position.Y -= deltaUp;
        }
        else if (deltaDown < deltaLeft && deltaDown < deltaRight && deltaDown < deltaUp)
        {
            Player.Instance.Position.Y += deltaDown;
        }
    }
}

I know this is ugly, but that's not the problem, the problem is that when it detects a collision, the player "spazzes out" and just bounces in and out of the rectangle it's colliding with. I've tried a couple other ways too, like just setting the player position without using absolute values, with similar calculations. The same problem happens though. Also it allows the player to just phase through platforms from one side, and the player will get teleported to other sides sometimes, so this is very bad.

I'm not sure how else to handle it, I've done research and googled a lot, as well as searched here, but everything I find is about the actual collision detection, which I'm doing via the Rectangle.Intersects() method. I've been at this for 3-4 days, before deciding to post here.


texts: The more appropriate way to find GameObject in the scene

texts:
Which way is the more appropriate to find GameObject in the scene.
I know that GameObject.FindGameObjectWithTag is faster than GameObject.Find but i wondering whether FindGameObjectWithTag is better solution than this:

public GameObject someObject;

public void SelectObject()
{
    someObject.SetActive(true);
    //or whatever i want
}


texts: Instead of using yield wait for seconds can I use a UI button for async?

texts:
the code below is the code I use to load my game scene ater the intro animation plays. The way it works is that it preloads the game scene because it is big enough it takes time to load and activates it after 15 seconds.

I want to use this code in a similar manner for my main menu, but instead of preloading and waiting for seconds I want it to preload and wait for UI button.

public class IntroToForest : MonoBehaviour
{
    public float WaitToLoad = 14.0f;

    void Start()
    {
        StartCoroutine(LoadScene(WaitToLoad));
    }

    IEnumerator LoadScene(float WaitToLoad)
    {
        yield return null;
        AsyncOperation asyncOperation = SceneManager.LoadSceneAsync("Forest Map");
        asyncOperation.allowSceneActivation = false;

        while (!asyncOperation.isDone)
        {
            if (asyncOperation.progress >= 0.9f)
            {
                yield return new WaitForSeconds(WaitToLoad);
                asyncOperation.allowSceneActivation = true;
            }
            yield return null;
        }
    }
}

Side note: I incorporated DmGregory's answer into my menu controller script and got this:

public class MenuController : MonoBehaviour
{
    public string SceneName;

    AsyncOperation preload;

    void Start()
    {
        preload = SceneManager.LoadSceneAsync(SceneName);
        preload.allowSceneActivation = false;
    }
    public void Go_to_game()
    {
        if (preload.progress < 0.9f)
        {
            if (PlayerPrefs.HasKey("HasSeenIntro"))
            {
            preload.allowSceneActivation = true;
            }
            else
            {
                PlayerPrefs.SetInt("HasSeenIntro", 1);
                SceneManager.LoadScene("Intro");
            }
        }
    }
}

The problem is that the UI button will not work.


texts: In a tile-based MMO, how do I decide which players need to receive what updates?

texts:
I am planning a tile based MMO, like Tibia or top down Minecraft. I'm using a client-server model. I've got almost everything figured out, with a notable exception of state updates.

When information about a tile changes (e.g. new item is added) all clients that see this tile need to be informed about it. How do I efficiently decide which clients needs to receive this update? I'd like to support on the order of 100 000s of tiles and 100s of players.


texts: Where can I find fonts (preferably free, but a reasonable fee is acceptable) that I can use in my for-pay/commericial game?


texts:
I need to know how to bind keys to actions through Javascript within Unity.

When I develop web applications, I normally use this:

var KeyBind = function() {
    if (document.addEventListener) {
        document.addEventListener("keydown", keyDownHandler, false);
        document.addEventListener("keydown", keyUpHandler, false);
    }
    else if (document.attachEvent) {
        document.attachEvent("onkeydown", function() {
            keyDownHandler(window.event);
        });
        document.attachEvent("onkeydown", function() {
            keyUpHandler(window.event);
        });
    }

    function keyDownHandler(e) {
        var key = e.which || e.keyCode;
        if (key == "27") {
            window.location="file:///D:/Users/pferris/Documents/Unnamed%20Site%202/HordeAttack.html";
        };
};

Does Unity use a similar method, or will I have to do something completely different?

I've been through the help section a bit, but nothing seemed very satisfactory.


texts: Blender - baking normal map - weird colors

texts:
I have a metal drum mesh, and when I bake its normal map, I get the weird colors (see attached pic). I'm talking about the horizontal gradient shift of color. There's no deformation like that on my mesh, how come the colors are like that? I've tried various spaces (camera, world, etc) but it's still bad (though the horizonal gradient changes with each one). Also tangent space returns a blocky blue color all over.

Can someone please tell me how to get a good normal map out of my mesh?

=== UPDATE

Solved, thank you very much Luke B. There's still the question of scaling one of the two overlapping versions a bit (the low res one for example) in order to get really good results, but that's how it's supposed to be done.

=== UPDATE 2

After further following the advices of Luke B, I've used multiresolution modifier on my low-res mesh, and baked from there. It looks much better than before, the color artifacting are down to a minimum, really, with some corrections in GIMP it's quite usable:


texts:
I have two bodies: one green static sensor (spikes) and one orange dynamic body (brick).

I have bullet and it's a dynamic body too, but with bullet flag set.

My problem is that when the bullet is moving left to right, it sometimes hits the orange brick instead of the spikes and it flies away. There is code to remove the bullet when it hits spikes. How can I make sure it hits the spikes first?


texts: Is this Code saving performance ? It is kind of a Occlusion Culling

texts:
I wanted to do Occlusion Culling on my Scene but I just get a bunch of Errors like "Couldn't load geometry..." etc. I tried to do like another way but the same thing, the Occlusion Culling just disables the Objects the Camera dont see.
I tried it with OnTriggerEnter and Exit.

I have 2 Areas one is on the left and one on the right, when the Player is walking in the first Area the Box Collider checks it and disables the Objects in Area2 but when Player is walking into Area2, Objects in Area1 disables and Different. Got the Script on both Areas that it disables a list of arrays as GameObjects.

My Question is, does this save performance ?

public GameObject[] deactivatingModels;
bool playerEntered = false;

void OnTriggerEnter (Collider other)
{

    foreach(GameObject envis in deactivatingModels)
    {
        if(other.gameObject.tag == "OcclusionCuller")
        {
            envis.SetActive(false);
            Debug.Log ("Player has entered Occuling Zone");
        }
    }
}

void OnTriggerExit(Collider other)
{
    foreach(GameObject envis in deactivatingModels)
    {
        if(other.gameObject.tag == "OcclusionCuller")
        {
            envis.SetActive(true);
            Debug.Log ("Player has left Occuling Zone");
        }
    }
}


texts: I am making a 2d platformer in java using the slick2d engine. I only use 2 colors: black and white. I want to implement a feature were i invert the colors of certain entities. However i can't find a way to do this. Anyone knows of an easy way or function?


texts: How to display the counter in pygame.time.set_timer?

texts:
in pygame, we use pygame.time.set_timer() to repeatedly create an event. This function takes 2 arguments : the event type and the delay time after which the event occurs in milliseconds.
For my case, that delay time is the reload time. So, i'm looking for a way to display that reload time on the screen. This is what i tried :
...
pygame.time.set_timer(pygame.USEREVENT+1, time)
...
reload_time = myfont.render(time, True, 'black')
myscreen.blit(reload_time, (670, 650))
...
pygame.display.flip()

This resulted in displaying the time delay value forever (it's not decreasing or resetting)
So what should i do?


texts: How can I test different TV display types for my XBLIG game?

texts:
The XBLIG submission check-list asks to ensure all gameplay-critical graphics be visible in the 'TitleSafeArea'.

I've received a bug report during play-testing that says parts of my scrolling 2D map are only half-visible (chopped off from the left of the screen).

I've tested the game on a 47" TV and a 19" VGA monitor and both look fine. However, the bug report says the issue occurs on a standard 20" TV.

How can I test different sizes without buying differently sized TVs?


texts:
We've started working with Unity 2018.3.0b11 recently, and this means we can now use newer C# features, which is amazing! However, every time I've restarted Rider, it starts complaining about any C# 7.0 features, like this:

The autofix is to allow ReSharper to suggest C# 7.0 features:

Opening the properties for the assembly will show that the language level has been set back to "latest":

If I change it to 7.3 specifically and close and re-open the settings, it now explains that the settings are overridden in the "Rider Settings" to C# 6.0.

If I click "Reset" it will then work, until the next time I restart Rider and it will be back to the first state above.

Using the "auto-fix" seems to take step one first (change to 7.0 specifically), still complaining though, and then if I do it a second time, it will do the second step ("Reset").

Is anyone else experiencing this with Unity 2018, and have you worked out a permanent fix?


texts:
I'm trying to implement a scene graph and in all the articles i've come across there is talk about object sorting. So you'd sort your objects by "material" for example. Now untill i sat down and started implementing it, i kind of took this for granted, because it made sense. But now i'm wondering what does sorting actually change?

In my engine, i have a manager for UBOs, i use those to store data that'll be shared between programs, at the moment that only involves time, camera and projection matrices and lights (i'm not worrying about managing which lights affect which objects ATM).

Now for each model i have to change the model to world matrix uniform, no sorting is going to change that. So is the jump from changing this matrix to also setting a material for each object that bad?

I vaguely remember reading somewhere that each time you change something in the pipeline, it has to get flushed and that can cause performance issues. But for each drawing call i'm setting up a model to world matrix anyway, so what sense does it make to ever be concerned about this?

BTW is there any information about whether changing a uniform and calling glBufferSubData is more (or less) expensive.


texts: How Do Objects Not Clip Out the Back of Thin Walls When Put Through a Portal?

texts: In Portal or Portal 2, let's say you pick up a cube and put it most of the way through a portal on a very thin wall. The cube should clip outside the backside of the wall. How does Portal do this, or how can this be done in general?


texts: How to destroy particles system after its work is over

texts: How can i stop particle system after player get destroyed


texts:
I am changing the Sprites on an array of Images.  I could think of two ways to go about it.  The first way being:

var images = GetComponentsInChildren<Image>();
foreach(var image in images)
{
    if (!image.sprite)
    {
        image.sprite = GetMySprite();
    }
}

This way works perfectly.  But if I try to grab the sprite itself like so:

var images = GetComponentsInChildren<Image>();
foreach(var image in images)
{
    var sprite = image.sprite;
    if (!sprite)
    {
        sprite = GetMySprite();
    }
}

It does not work.  The Sprite gets assigned, but it is not the original Sprite.  The Sprite attached to the Image remains null.

At first I thought, maybe Sprite is a struct? But it is not - it is a sealed class extending Object.  (And I don't think that would necessarily explain it anyways).

So why must I retain the reference to the Image when changing its Sprite attribute?

Relative Documentation:
Unity Image, Unity Sprite


texts: Can I include PCM audio data in a commercial application?

texts:
For certain reasons, I need raw audio data in my application. I would convert certain sounds to a PCM format (at development time), and store & load these PCM files in my game.

PCM stands for Pulse Code Modulation, and as far as I can see, it is a representation of signal, and thus cannot be patented by anyone. Only formats can be patented I suppose (e.g. WAV, which relies on PCM), but PCM sequence of bits cannot be.

So if I include PCM data in my application package, I don't violate any patent, do I?

I'm developing for Android, by the way.


texts:
I am creating a roguelike which will use an ASCII based tile set. There is a text file that represents the map (ie. walls, floor, items). I believe the next steps are to read this file in and use a 2D array to hold objects that represent each of the characters.

My question is, is there a more efficient way to parse through that file and create the object map without using one huge switch statement to create the proper object? If not, is there a better approach I can take overall?


texts: So I've been trying to build my unity project for android, but my problem is that I don't know how to find the Android SDK. I have the old developer bundle installed, when it was still the one with eclipse, but this version is not supported by Unity. So, I installed the latest version of Android Studio, the new official Android IDE, but the SDK folder is not in the same place as the rest of the program. How would I find the SDK folder for Android Studio so I can build my Unity project?


texts: Draw lines from the center of the screen at specific angles

texts:
I want to draw multiple primitive lines which start at the center of the screen and end at the edges of the screen, traveling at specific angles:

How can I set the angle for each line?

Here is my code where I draw only one line from the middle of the screen to the top of the screen.

LineVertices = new VertexPositionColor[2];
LineVertices[0].Position = new Vector3(graphics.GraphicsDevice.Viewport.Width / 2, graphics.GraphicsDevice.Viewport.Height / 2, 0);
LineVertices[0].Color = Color.Red;
LineVertices[1].Position = new Vector3(graphics.GraphicsDevice.Viewport.Width / 2, 0, 0);
LineVertices[1].Color = Color.Red;
.
.
.
//Draw call
graphics.GraphicsDevice.DrawUserPrimitives<VertexPositionColor>(PrimitiveType.LineList, Line2Vertices, 0, 1);


texts: Is frustum culling necessary in a Flash/AS3 game?

texts:
I'm making a 2D game where the map will be scrolled frequently, and only a small part of it will be visible at any time.

Which implementation would run faster?

The naive way: Make the map a single
huge MovieClip and move it around.
The elegant way: Split the map into
multiple chunks and use a frustum
culling algorithm to render only the
ones that are visible.

Now that I think of it, this question boils down to whether Flash does its own frustum culling on big MovieClips.


texts: Strange momentum on projectiles shot out of "parent" object

texts:
I'm trying to shoot a projectile out of a moving "parent" object. Both objects move off of rigidbody physics, so I'm using addforce for the projectile.
Whenever I move the "parent" object and turn while it's moving and shoot the projectile, I instantiate the projectile, copy the projectile spawn position to the projectile's position, copy the rotation of the "parent" to the projectile, then add force to the projectile.
It'll shoot but I notice it moves in the direction of the momentum of the "parent" rather than straight forward from where it was created. I'm pretty sure this is just me not understanding how rigidbody physics works for adding force but if anyone has any suggestions as to how to make the projectile move straight forward from where it's created rather than copying the momentum of the parent I'd appreciate it greatly.
My code for moving and creating a projectile looks like this:
void FixedUpdate()
{

    if (Input.GetKey(KeyCode.W))
    {
        //player.transform.Translate(Vector3.forward * 10f * Time.deltaTime);
        this.GetComponent<Rigidbody>().AddForce(transform.forward * 15);
    }
    if (Input.GetKey(KeyCode.S))
    {
        this.GetComponent<Rigidbody>().AddForce(transform.forward * -15);
    }
    if (Input.GetKey(KeyCode.A))
    {
        transform.Rotate(Vector3.up * -15 * Time.deltaTime);
    }
    if (Input.GetKey(KeyCode.D))
    {
        transform.Rotate(Vector3.up * 15 * Time.deltaTime);
    }
}

void ShootBullet()
{
    //create bullet GameObject
    bullet = Instantiate(bulletPrefab);

    //set location where bullet will spawn from
    bullet.transform.position = bulletSpawn.position;

    //set direction of the bullet
    bullet.transform.rotation= bulletSpawn.transform.rotation;

    //add force to the bullet
    bullet.GetComponent<Rigidbody>().AddForce(bulletSpawn.forward * bulletSpeed, ForceMode.Impulse);

    //destroy bullet after x time
    Destroy(bullet, lifeTime);
}


texts: How do I load a specific Asset Bundle Manifest, but not the Asset Bundle itself?

texts:
I have a bunch of Asset Bundles.  I load the generic Asset Bundle Manifest to get the names of all of my asset bundles.  I want to load only a specific asset from the bundle, but I need to retrieve the names of the assets so I can choose which one.  The names of these assets are in the asset bundles manifests associated with each asset bundle.

How can I load just the manifest for a particular asset bundle?

This is the closest I have come, but it does not work:

private IEnumerator LoadAssetNames()
{
    foreach (var bundleName in assetBundleNames)
    {
        string url = "my://server/" + bundleName + ".manifest";
        var www = UnityWebRequest.GetAssetBundle(url);
        yield return www.Send();
        if (www.isError)
        {
            Debug.LogError(www.error);
            yield break;
        }
        var bundle = ((DownloadHandlerAssetBundle)www.downloadHandler).assetBundle;
        www.Dispose();
        assetNames[bundleName] = bundle.GetAllAssetNames();
    }
}

It returns to me a failed to decompress error:

Error while downloading Asset Bundle: Failed to decompress data for the AssetBundle 'my://server/bundleName.manifest'.

I can download the manifest directly as a string or set of bytes, but then how can I cast it to an AssetBundleManifest?


texts: NullReferenceException: Object Reference Not Set to an Instance of an Object (How is that so and I should I solve it?)

texts:
I am stuck several days because of this problem, which I am almost on the verge of giving up. (Using Unity Engine 2019.3a by the way). The TextButtonName.text can't read what TextButton is throwing to it. Meanwhile, when I did a Debug.Log test, the console shows what is the text in the TextButton. What the console showed about Debug.Log() thing should be the value of a variable assigned (hence, the

Is there any way that whatever is the text at the button, will be the value that can be used for Switch Statements? If there is a way (I am sure there is), how? Thanks.

//When pressed, ButtonPress() will be triggered and will go to Experiment Information Scene
public void ButtonPressTutorial(){
    //TextButton = gameObject.GetComponentInChildren<Text>().text;
    TextButton = EventSystem.current.currentSelectedGameObject.GetComponentInChildren<Text>().text;
    TextButtonName.text = TextButton;
    /* TextButton, although has value shown in Debug.Log, the problem is that
    it throws a NULL value when being thrown to TextButtonName.text Why is that? Is there that I need to do?*/
    Debug.Log(TextButton);
    SceneManager.LoadScene(5);}

Switch statements:

        switch (TextButtonName.text) {
        case "  Tutorial":
            ExpNum.text = "Tutorial";
            ExpTitle.text = "Coke With Mentos Experiment";
            ExpDetails.text = "//Details will be shown here";
            break;
        case "Experiment 1 Button":
            ExpNum.text = "Experiment 1";
            ExpTitle.text = "Lemon Volcano Experiment";
            ExpDetails.text = "//Details will be shown here";
            break;
        default:
            ExpNum.text = "No Experiments";
            break; }


texts: iPhone Open GL ES using FBX - How do I import animations from FBX into iPhone?

texts:
I've been researching this extensively.

We have a game that's 90% complete, using custom game logic in iPhone 4.0. We've been asked to import a 3D model and have it animate when various events happen in the game.

I've put together an OpenGL view (based on Eagl and several examples), and used Blender to import the model, as well as Jeff LeMarche's script to export the .h file. After much trial, it worked, and I was able to show a rotating model (unskinned).

However, the 3d artist hadn't UV unwrapped the model, so provided me a new model, this one as a Maya file, along with animation in a FBX format, a .obj file, and .tga texture unwrapped.

My question is : how can I use FBX inside OpenGL ES inside iPhone to run through animations? And what's the pipeline to get this Maya file into Blender to be able to create a .h file. I've tried the obj2opengl however the model is missing normals (did it have it in the first place?) and the skin isn't applying at all (possibly a code issue, something I think I can fix).

I'm trying to use Jeff LeMarche's animation tutorial but can't figure out how to get the model files into a proper .h file for use.

Any advice?


texts:
For a final school project, I have implemented an A* algorithm for pathfinding across a tile graph. So far, it has worked far surpassing my expectations. However now I'm in the process of adding a bit more complexity to the level and I am not sure that tile graphs will cut it any longer.

I would like to add multiple floors, but for the sake of simplicity I will just create two floors. At the present moment, I have a 2D array of Nodes that represent the single floor in a level. I don't think this will be scalable any more to anything besides one floor. I am proposing a method to find paths across two floors using multiple clusters containing nodes for different sections of the map where some nodes are flagged as exit nodes that will lead to other clusters.
 Moreover exit nodes will also be marked for the ones that lead up stairs to a second floor. The heuristic cost of moving from one floor to another will be higher than if an agent was to simply move across the same level.

I'm thinking if an agent is trying to traverse from one path to the next, it first checks to see if the start node and exit node are on the same floor. If so, then the cost is simply the euclidean distance, otherwise it tries to find the path to the exit node on the cluster it's currently on, compute the path to that node, then compute the cost to the next exit node within that same cluster. Repeat ad nauseam.

So as a visual representation of this, this is a terrible representation of a floor plan. The only highlighted nodes are the exit nodes

This is what I could come up with. Is there any other way besides searching through a ton of tiles and clustering? So far on a tile of 100X100 performance seems to be ok and not an issue. I have heard of using nav meshes, but I'm not entirely sure how to implement them in my project. Since this class is an advanced game development class, if we do use nav meshes, we need to create and implement our own and not use Unity's built in navmesh


texts: How do I draw a line using jme3.scene.shape.Line in JMonkeyEngine 3.0?

texts:
I can successfully create the object, but it can't be attached to the rootNode. What can I do to make the line appear?

I'll also would like to know how to reverse the effect(making it disappear) shortly after if any special steps are involved.


texts: Most efficient way to hide out of bounds object in tile based environment

texts:
I am working on a desktop game in C#, with Monogame framework. I am storing the tile instances in a 2D Array, for the sake of easy collision detection. But the levels are big (often 100x100 or bigger) and there are lots of tiles out of the screen bounds all the time which I should not draw. At the moment I'm running through the arrays and checking whether they are in the screen bounds or outside, but that may not be too efficient due to the big count of the tiles.

Is there any better way to hide out of bounds tiles?


texts: Taking cube from camera space to clip space, error in my math?

texts:
watching Ken Joy's Computer Graphics lectures on youtube. One thing I'm confused about is after he gets the cube from the camera space to clip space, from my calculations the cube doesn't look like that. I expected the cube to look like that pink parallelogram in my picture, if we assume the Z of the front-face of the cube to be -4/3 and the back-face to be -2 then the Ws come out to be 4/3 and 2 respectively. So can someone explain how after multiplying by the viewing matrix, the cube comes out to look like how Ken has it.

Ken's view matrix:

After view matrix has been applied:

What I think the side of the cube should look like(the pink parallelogram) after view matrix has been applied:

my reasoning is, after the perspective divide by W, the blue and green vectors should get truncated to create that pink parallelogram. So I'm struggling to understand this. Thanks in advance.


texts: Spawning moving text make it disappear overtime

texts:
I am trying to display a text when I click the letter 'R'. When the text appears, it should slowly slide down on the y axis only, slowly disappear over 4 seconds and get disabled.

I am not able to find any clear guidance on the new UI. Most are just telling how to insert and move them on the Unity Editor and not able to find anything on scripting and the documentation doesn't seem to have a clear description focused on UI scripting either (or maybe I am just that bad at reading it).

The following script makes the Text appear when I press the letter 'R'. It does disappear after 4 seconds. But it doesn't move down the y-axis and I am not able to assign the alpha value to the text incrementally to make it disappear over the 4 seconds.

Have commented the errors encountered below. I am testing this class separately on a separate Project altogether so no other interference. The Script is attached to an Empty Object on the scene.

    using UnityEngine;
    using System.Collections;
    using UnityEngine.UI;

    public class TextScript : MonoBehaviour
    {
        public Text Text1;
        private float count;
        private float scrollDown, alpha, duration;

        void Start()
        {
            count = 0;
            scrollDown = 660;
            alpha = 4;
            duration = 1.5f;
            StartCoroutine(WaitAndPrint(2.0F));
        }

        void Update()
        {
            TextSpawn();
            KeyCount();
        }

        //spawn the Text on the screen when count is higher than 1
        //text should slowly move down on the y axis
        //same time its Color alpha should go down too and making it disappear and when alpha is zero, disable the text.
        void TextSpawn()
        {
            if (count >= 1)
            {
                Text1.enabled = true;
                Text1.color = Color.black;
                Text1.text = "Text 1 !";
            }

            if (alpha > 0)
            {
                //if I use the variable scrollDown instead of 660, the Text will not appear on screen

                Text1.transform.position = new Vector3(748, scrollDown, transform.position.z);

                //this line of code will make the Text jump in the Y axis to 1620 even before I press 'R'
                //scrollDown += 10f;

                alpha -= Time.deltaTime / duration;

                //trying to set value to alpha which is not accepted.
                //Text1.material.color.a = alpha;
            }
            else
            {
                Text1.enabled = false;
            }
        }

        //Using this to increment count and enable the Text
        void KeyCount()
        {
            if (Input.GetKeyDown(KeyCode.R))
            {
                count++;
            }
        }

        //Using this to find out the position of the text for testing
        IEnumerator WaitAndPrint(float waitTime)
        {
            yield return new WaitForSeconds(waitTime);
            Debug.Log(Text1.transform.position);
        }
    }


texts: How can I scale player/enemy stats to balance the difficulty just right?

texts:
I'm creating an old school top-down grid based RPG, where you enter random encounters every few steps.  I want to know what kind of systems or guidelines there are for creating the leveling and stats system for such a game.  Right now I'm just sort of guessing based on intuition and it's clear that that isn't going to work for very long.

For example, let's say I have a max level cap of 50, and 10 dungeons.  The ideal would be that the player should need to gain about 5 levels per dungeon in order to stand a chance in the next dungeon, but that the monsters in the current dungeon can't provide enough XP to skip the next dungeon (within a reasonable amount of time anyway).

The easy route that I can think of would be to just define every enemy as worth 1 XP, and then set the amount of XP required for the next level in increasing increments, so that I only really have to track number of kills (level 1 --> 2 would be 10 XP, or 10 kills, level 2 --> 3 would be 12 XP, or 12 kills, etc.).  But that's boring.  As a player myself, I like to see the numbers related to my actions get larger over time (i.e. at level 1 --> 2 as 10 XP, but level 2 --> 3 as 150 XP, etc.).

And that's not even counting for stats like Strength, Vitality, and so on.  But that in itself is a whole other question: are there any kinds of formulas for stats and their effects on each other?  For example, enemy has 50 armor, and my guy has 30 strength.  That is considerably more armor than strength, so I would expect my hit to be pretty weak...but how can I calculate those statistics to get a final damage number?

Are there any guides or any kind of "standards" for such basic systems?  Even if "every game is different," I still need to learn the absolute BASIC ideas for "most" games.  I have questions such as, "if you have an agility-like stat, what is a common way to determine dodge rate?" and so on.

EDIT: I found this after posting, but I'm gonna include the link here if someone else stumbles across this with similar questions.  Balancing Player vs. Monsters: Level-Up Curves


texts: How can I carry around an inventory in my inventory?

texts:
I'm working on a mod for soul gems in Skyrim and want to add something like a Bag of Holding from souls.

The most simplyfied strategy I can come up with is

Create an invisible Black Soul Gem to catch a trapped soul in inventory
Create an item to act as representation of the soul wallet in inventory
Create an invisible container somewhere to store the souls and link it to the above
Create a script that detects soul trap and transfers it from inventory to soul wallet as a real black soul gem (or whatever is needed).

Ideally I'd want to make this a little more balanced that just handing out soul gems like candy but I think I could do that on my own once I actually get this far.

So this is about both parts (now):

How can I carry around an inventory within my inventory?
How can I detect that a soul has been captured (in my invisible gem)?


texts:
I have a 3D cube that can be rotated with the mouse to show any side of the sphere.I want to be able to click a point on the cube and draw a circle around that point at a fixed height(so i dont need depth information), however i run into a problem where i cant translate the screen coridiantes to the worldspace coordinates. What i have attempted:

get mouse click position(x,y)
normalise the screen position(-1 to 1)
create a vector with the z coordinate as 1
multiply the vector by (inverseProjection x inverseView)

However, this does not give me the world coordinates as i would have expected. Where am i going wrong?

The depth information is not needed form this, i only need to map the mouse click point (x,y) to the world point (x,y,z) where z is fixed.

DirectX::XMMATRIX projection = projectionmatrix();
DirectX::XMMATRIX view = viewmatrix();

DirectX::XMMATRIX invProjectionView = DirectX::XMMatrixInverse(&DirectX::XMMatrixDeterminant(view *  projection), (view *  projection));
//invViewProjection = invView * invProjection;

float x = (((2.0f * mouseX) / _viewport.Width) - 1);
float y = -(((2.0f * mouseY) / _viewport.Height) - 1);

DirectX::XMVECTOR mousePosition = DirectX::XMVectorSet(x, y, 1.0f, 0.0f);

mouseInWorldSpace = DirectX::XMVector3Transform(mousePosition, invProjectionView);

Edit: The fixed axis is the y-axis, the z and x axis are the changing axis

Edit: I have revised the question after realising my mistakes in the initial question.

The x, y, and z are positioned as shown above. I want to be able to click the cube surface and drwaw the shape at a point with a fixed y-offset from the click point.

I am not able to draw a plane on the surface of the cube due to the nature in which the cube is generated hence the need for the screen to world coords.


texts: Investigation stage before starting a game

texts:
I was thinking about how to organize the stage about getting informed about whatever game is needed to develop, what would others do.

For example, if I wanted to develop a game about car racing, I should figure out all the factors during the race, from the car factor to the pilots, etc., environmental factors like weather, circuit conditions, etc.

How does one manage this stage?

Thanks.


texts:
I have a white circle sprite. I know how to change its color to a solid fill color. using GetComponent<Renderer>().material.color.
But how would I give it a gradient fill color.

I've been trying to do this with a shader.
But so far the shader I've created doesn't take the circle sprite into account, simply its bounding box. It also looks a bit weird.

here's my shader code

   Shader "Custom/SpriteGradient" {
 Properties {
 [PerRendererData] _MainTex ("Sprite Texture", 2D) = "white" {}
 _Color ("Left Color", Color) = (1,1,1,1)
 _Color2 ("Right Color", Color) = (1,1,1,1)
 _Scale ("Scale", Float) = 1
 }

 SubShader {
 Tags {"Queue"="Background"  "IgnoreProjector"="True"}
 LOD 100

 ZWrite On

 Pass {
     CGPROGRAM
     #pragma vertex vert
     #pragma fragment frag
     #include "UnityCG.cginc"

     fixed4 _Color;
     fixed4 _Color2;
     fixed  _Scale;

     struct v2f {
         float4 pos : SV_POSITION;
         fixed4 col : COLOR;
     };

     v2f vert (appdata_full v)
     {
         v2f o;
         o.pos = mul (UNITY_MATRIX_MVP, v.vertex);
         o.col = lerp(_Color,_Color2, v.texcoord.x );
         return o;
     }

     float4 frag (v2f i) : COLOR {
         float4 c = i.col;
         c.a = 1;
         return c;
     }
         ENDCG
     }
 }
 }


texts: How to spawn objects and control the content in each spawn

texts:
I'm using unreal engine and would like to spawn multiple actors and control the text in each spawned actor.

How can this be achieved in unreal engine?


texts: Efficient systems in an Entity Component System

texts:
I'm designing a simple Arcanoid game with ECS.

With ECS there are many systems that only update components once in a while. For example, Particle systems are animated sprites that can be used for collision effects or explosions. These kind of effects happen rarely.

ParticleSystem will only update ParticleComponent when they exist, which happens rarely, just on collisions, etc. The rest of the time it's polling to find entities with ParticleComponent.

Isn't this polling inefficient? If I have many more functions similar to the ParticleSystem, that only do work rarely, the update will be clogged with systems that do not update anything. Would it be good practice to "sleep" the system until an entity is assigned to the ParticleComponent?

For example (using EntityX):

class ParticleComponent : Component<ParticleComponent>
{
public:
    ParticleComponent(ParticleId id) : id(id), time(0.0){};

    ParticleId id;
    double time;
};

class ParticleSystem : System<ParticleSystem>
{
public:
    void update(EntityManager & entities, EventManager & events, TimeDelta dt)
    {
        // this list will be empty if there are no entities.. but there is still a search
        entities.each<ParticleComponent>([](Entity & entity, ParticleComponent & particle)
        {
            // update current animation time
            particle.time += dt;
        });
    }
};

class Game : public EntityX
{
public:
    Game()
    {
        systems.add<ParticleSystem>();
        systems.configure();
    }

    void update(TimeDelta dt)
    {
        // this is only useful when there are entities with ParticleComponents
        systems.update<ParticleSystem>(dt);
    }

    void onRareEvent()
    {
        auto entity = entities.create();
        entity.assign<PositionComponent>();
        entity.assign<ParticleComponent>(FIRE_PARTICLE);
        // destroy in 3 seconds
        timer.schedule(3, Game::destroyEntity, entity);
    }

    //void render()...
}


texts: Getting a CineMachine FreeLook Camera to work with a GamePad(joystick)

texts: I have no idea how to get the FreeLook cam to work with the second stick on a gamepad. The docs seem to have nothing on the topic. Has anyone done this before ?


texts: Hardware acceleration for the Flash Player

texts:
What do we know about hardware acceleration for drawing operations in Flash? I know that since 10.1 it's there for video playback (and mobile graphics) but that doesn't really help with rendering desktop game graphics.

So, is there any information about it, or maybe talk or rumours going around? Do you think it's something we'll get at all within a reasonable period?

I personally really keep hitting the ceiling with Flash' software renderer. A game scene that, were it hardware accelerated, my PC from 2003 could render while sleeping, runs at a low 20 fps on my quad core laptop. It's a shame because the Flash VM is otherwise rather fast.

Or maybe I am wrong and Flash is already using the GPU, and my games are slow for other reasons?


texts: Using AddForce() to implement a follow script

texts:
Not looking for an implementation to the problem (although that would be good :P), mainly looking to be pointed in the right direction for solving it.

Basically, I want to have various game objects following a single game object, using rigidbody.AddForce(). This is to allow for realistic physics simulations as collisions will be a key part of this and using anything but rigidbody.AddForce() doesn't really allow for it.

I have been working on implementing this, but the GameObjects which are following always tend to overshoot their target, or they can't quite stop in time when applying reverse force to slow them.

As I've said, I'm mainly looking to be pointed in the right direction, be it some mathematical formulae that I require, or another method that I am overlooking. With that said, a very simple implementation to build-on would be awesome.

All help is greatly appreciated!

Thanks!


texts: HTML5 canvas screen to isometric coordinate conversion

texts:
I am trying to create an isometric game using HTML5 canvas, but don't know how to convert HTML5 canvas screen coordinates to isometric coordinates.
My code now is:

var mouseX = 0;
var mouseY = 0;
function mouseCheck(event) {
    mouseX = event.pageX;
    mouseY = event.pageY;
}

which gives me canvas coordinates. But how do I convert these coordinates to isometric coordinates? I am using 16x16 tiles.


texts:
I am trying to draw a 2d game map and the objects on the map in a single pass.
Here is my OpenGL initialization code

// Turn off unnecessary operations
glDisable(GL_DEPTH_TEST);
glDisable(GL_LIGHTING);
glDisable(GL_CULL_FACE);
glDisable(GL_STENCIL_TEST);
glDisable(GL_DITHER);
glEnable(GL_BLEND);
glEnable(GL_TEXTURE_2D);

// activate pointer to vertex & texture array
glEnableClientState(GL_VERTEX_ARRAY);
glEnableClientState(GL_TEXTURE_COORD_ARRAY);

My drawing code is being called by a NSTimer every 1/60 s.
Here is the drawing code of my world object:

- (void) draw:(NSRect)rect withTimedDelta:(double)d {
  GLint *t;
  glActiveTexture(GL_TEXTURE0);
  glBindTexture(GL_TEXTURE_2D, [_textureManager textureByName:@"blocks"]);
  glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);

  for (int x=0; x<[_map getWidth] ; x++) {
    for (int y=0; y<[_map getHeight] ; y++) {
      GLint v[] = {
        16*x ,16*y,
        16*x+16,16*y,
        16*x+16,16*y+16,
        16*x ,16*y+16
      };

      t=[_textureManager getBlockWithNumber:[_map getBlockAtX:x andY:y]];

      glVertexPointer(2, GL_INT, 0, v);
      glTexCoordPointer(2, GL_INT, 0, t);
      glDrawArrays(GL_QUADS, 0, 4);

    }
  }
}

(_textureManager is a Singelton only loading a texture once!)
The object drawing codes is identical (except the nested loops) in terms of OpenGL calls:

- (void) drawWithTimedDelta:(double)d {
  GLint *t;
  GLint v[] = {
    16*xpos ,16*ypos,
    16*xpos+16,16*ypos,
    16*xpos+16,16*ypos+16,
    16*xpos ,16*ypos+16
  };
  glBindTexture(GL_TEXTURE_2D, [_textureManager textureByName:_textureName]);

  t=[_textureManager getBlockWithNumber:12];

  glVertexPointer(2, GL_INT, 0, v);
  glTexCoordPointer(2, GL_INT, 0, t);
  glDrawArrays(GL_QUADS, 0, 4);
}

As soon as my central drawing routine calls the two drawing methods the second call overlays the first one. i would expect the call to world.draw to draw the map and "stamp" the objects upon it. Debugging shows me, that the first call is performed correctly (world is being drawn), but the following call to all objects ONLY draws the objects, the rest of the scene is getting black.

I think i need to blend the drawn textures, but i cant seem to figure out how.

Any help is appreciated.
Thanks

PS: Here is the github link to the project. It may not be in sync of my post here, but for some more in-depth analysis it may help.


texts: Art style for a character that has frequent visual changes during gameplay

texts:
I'm creating a game with a bodybuilding/fitness theme. The camera will almost always be focused on an inclined front view of a character who will be evolving very frequently during the game as the player 'levels up' the musculature of each part of the character such as arms, legs, chest, etc.

I've been doing some research trying to figure out the most economical yet effective way to incorporate this visual mechanic of letting individual parts of a character independently increase in size and detail and have come up somewhat short, most likely due to my complete lack of experience when it comes to art (my experience is mostly in programming).

I was thinking 2D would be best for this game, however maybe this one character should be in 3D? Would a low poly style fit these requirements, or should I look towards something akin to sprites or hand drawings? The games interactivity will be purely through menus so that doesn't need to be taken into account when dealing with the problem of this character. I would like this character to have some animations, of course, however I'm not sure if that fits the scope of this single question.


texts:
I have many diffrent animations made with flash.
I can make it as (1).SWF, (2).GIF or as (3).PNG (every Frame per second).
Searched in google... but coudn't find anything usefull.

SWF: For SWF i need Flash on the android phone... this is something new to me and because of that i woudn't prefer a solution with that.
-> I heard that Flash is not supported on Android for a long time, so this does not work.
GIF: If that is possible it woud be very nice. I'm thinking of something like "animation1.start();".  But i heard that android can't handle GIF.. -.-
PNG: I know how to animate many .png pictures with an animationdrawable but when i export the animations into a .png for every frame in the second... imagion how many pictures i have. The problem is that i can't make subdirectorys in the drawable folder. Why? I don't have a clue. :/ But realy, that woud suck.

Do anyone have any solution to that than pls feel free to tell me. :)

Edit:
I didn't finde a easy solution so i will make it with animationdrawables.
If you have a solution... pls pls answer here :)


texts: Can I test collision inside an edge collider area in Unity?

texts:
I have a triangle with its perimeter represented by an EdgeCollider2D, and I want to trigger an event when the player reaches this area.

So I set the collider as a trigger and, I used the OnTriggerStay2D function in my code.

But the event works only when the player is intersecting the line of the collider, not when the player is inside the triangle but not touching the edge.

How can I continue to get OnTriggerStay messages when I'm inside the triangle, not touching the edges?


texts:
I'm currently building my own game using LIBGdx in JAVA but i'm facing some trouble. My game is base like this :

A player have a position and some other parameters that are float, int types. He also have a class name Launcher that contains 3 array list and every update of my game it sends way to much datas and it's making the game very laggy.

How my system work :

Serveur launch and is waiting for connection in another thread. Meanwhile the main thread of the server is updating the map. Suddenly a player connect to the server, it add a new PlayerGestion inside the server which allows me to receive update from this single player. Meanwhile the server keeps updating the maps with the players datas. My problem is that after every map update, when the server send datas to every players, it sends heavy datas that is the arraylist of players (containing the datas i listed below).
So my question, is :

Is the way i'm doing a client / server good ?

Is the writeObject method good to use in a server / client

Is it possible to do an online by sending only the x / y players position ?

I'll be able to answer more question if you need to and show some line of code if it can help you help me.

Thanks !


texts:
When I visualise a three dimensional rotation matrix, or scaling matrix I visualize it as three axes.

Is there a similar way that I can visualize a rotation quaternion?


texts: ECS: is it beneficial to manage the data organisation of components before updating a system?

texts:
When I process a bunch of component data, I'd like that data to be sorted in such a way that I can iterate through the component buffers linearly. For instance when I want to update the physics system, in an ideal world the buffers for the TransformComponent, MovementComponent and PhysicsBodyComponent are structured in such a way that I would be able to iterate over the entities like this:

for(int i = 0; i < m_numEntitiesInSystem; i++)
{
    Transform& transform = g_transformBuffer[i];
    MovementComponent& movement = g_movementBuffer[i];
    PhysicsBodyComponent& body = g_physicsBodyBuffer[i];
    // ... update physics ...
}

The main advantage of this is that I would have next to no cache misses for this system. Because different systems require different (combinations of) components, this would imply that before every system update, I would either have to sort the respective component buffers so that they are aligned or I would have to use a cache that is local to the system only (this cache would need to be synced every time a component changes).

Of course both approaches come at a cost as well, sorting the component buffers could affect the ability to execute systems on separate threads. Not to mention that the sorting process itself might have its own performance drawbacks.
Syncing the component data implies that some components might need to be copied over possibly several times per frame which again might come with its own performance drawbacks.

My question is: is the price of sorting or syncing worth being able to process data linearly? Or is it wiser to try organise the data in such a way that the most executed/expensive systems perform optimally and others potentially less so. If the former, would it be preferable to use the sorting method or the syncing method?

Also please don't tell me that "premature optimization is evil". Since this is more or less the foundation of my engine, I want it to be as well written and designed as I can. Or at least I want to understand the consequences of picking one method over the other.

Thank you so much!


texts: 2D Collision response - rotating, moving polygon hitting a wall

texts:
I'm trying to bounce a polygon that has both velocity and angular velocity off a (immovable) wall when one of the vertices collides with it. I can detect the collision, and I've worked out how to calculate the inputs and know what outputs I need, but haven't been able to find or work out an implementation for the response. Any help would be greatly appreciated.

function collisionResponse(
    c, // object center of mass position
    v, // velocity of object
    a, // the angular velocity of the object
    p, // point of contact with line
    n  // normalized normal of line
) {
    //  Make a vector from center mass to contact point
    cp = p - c;

    //  Total velocity at contact point (add angular effect)
    pv.x = v.x - cp.y * a;
    pv.y = v.y + cp.x * a;

    //  Reflect point of contact velocity off the line (wall)
    rv = reflect( pv, n );

    // magic happens..

    result.v = ?? // resulting object velocity
    result.a = ?? // resulting object angular velocity
    return result;
}


texts: Isometric tilemaps character sort problem

texts:
I've been trying to make a little isometric game where the character moves freely through tiles.
I made the camera option custom axis and changed x=0, y=1, z=0
The problem I run into is that the character doesn't appear properly, in the middle of the tilemap I see this blue circle which indicated pivot of tilemap? If the character goes above it, it will disappear.
What I wanted to achieve was to have multiple tilemaps like: base, elevation1, elevation2, etc, so the character can appear behind elevations but in front of the current tile it's standing on. How do I make this work?


texts: How do I make a specific script always operate at Time.timeScale = 1 no matter what? I want it to override even when another script calls Time.timeScale = 0 for example.


texts: Float, double or both for 2D Vector class?

texts:
I'm currently writing a small cross-platform OpenGL-based 2D game engine for our studio. When I researched which 2D Vector class to use, I stumbled across three different design paradigms:

Float & Call-by-value, like in this Gamasutra article. Seems to be fast but offers little precision (see also this Thread). Pro: Fast, portable and compatible with most libraries.
Double & Call-by-reference. If I understand the above article right, I could also use 2 double precision variables instead of the 4 float numbers. According to the above thread double's still slower than float.
Template for double and float: The widely popular book "Game Engine Architecture" uses templates to make it possible to use float and double as needed. The obvious downside is code bloat. Also, I doubt it that the code can be optimized without basically writing two classes, anyway.

I would appreciate to learn what solutions you're using in your in-house engines and how precise e.g. popular game engines are, so I can decide what solution I'll implement in our engine. In the moment I'm thinking about simply using float precision and live with it.


texts: How can I get the assignment of an object back?

texts:
I have been struggling with this NullReferenceExpection error.

When I don't add anything and just use this version of the code. The game adds a tower, upgrades a tower and takes money for it.

It worked all fine until I tried to add a menu that opens up and then you can choose a tower type you can buy.

So after I add all of this I get a NullReferenceExpection at return tower == null && gameManager.Gold >= cost; and at gameManager.Gold -= tower.GetComponent<TowerData>().CurrentLevel.cost;. The game also doesn't take any money from purchases and you can spawn near infinite amounts of towers on one spot.

  //tower = (GameObject)

  theTowerMenu.gameObject.SetActive (false);

  transform.position = new Vector3(openSpot.transform.position.x, openSpot.transform.position.y, transform.position.z

If i take 'tower = (GameObject)' out of comments I get "error CS0030: Cannot convert type void' toUnityEngine.GameObject'".

The current script:

using UnityEngine;
using System.Collections;

public class PlaceTower : MonoBehaviour {

public GameObject towerPrefab;
private GameObject tower;

public GameObject openSpot;

private GameManagerBehavior gameManager;

public GameObject theTowerMenu;

// Use this for initialization
void Start () {
    gameManager = GameObject.Find ("GameManager").GetComponent<GameManagerBehavior>();
}

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

}

private bool canPlaceTower() {
    int cost = towerPrefab.GetComponent<TowerData> ().levels[0].cost;
    return tower == null && gameManager.Gold >= cost;
}

void OnMouseUp () {
    if (canPlaceTower ()) {
        //tower = (GameObject)
        theTowerMenu.gameObject.SetActive (false);
        transform.position = new Vector3(openSpot.transform.position.x, openSpot.transform.position.y, transform.position.z);
        Instantiate (towerPrefab, transform.position, Quaternion.identity);

        AudioSource audioSource = gameObject.GetComponent<AudioSource> ();
        audioSource.PlayOneShot (audioSource.clip);

        gameManager.Gold -= tower.GetComponent<TowerData>().CurrentLevel.cost;
    } else if (canUpgradeTower ()) {
        tower.GetComponent<TowerData> ().increaseLevel ();
        AudioSource audioSource = gameObject.GetComponent<AudioSource> ();
        audioSource.PlayOneShot (audioSource.clip);
        gameManager.Gold -= tower.GetComponent<TowerData> ().CurrentLevel.cost;
    }

}

private bool canUpgradeTower() {
    if (tower != null) {
        TowerData towerData = tower.GetComponent<TowerData> ();
        TowerLevel nextLevel = towerData.getNextLevel ();
        if (nextLevel != null) {
            return gameManager.Gold >= nextLevel.cost;
        }
    }
    return false;
}
}

Please help. I've been stuck with this for a long time.


texts: How can I implement a "horizontal desynced colors" effect in LWJGL?

texts:
My plan is to achieve analog video effects like RGB channel desynchronisation.

I'd like to have something like this (I hope you get the idea):

Left: White dot; Right: The same dot, but mind the channel offsets (the center should be brighter and white).


texts: why command is not executing on local player

texts:
I am getting very strange behavior, if my player instantiate as host (Server+Player) then my command function runs perfectly and certain object become instantiate but if I join the host then my Command doesn't execute on my local player but runs on all other clients.

void Start()
{
    if (isLocalPlayer)
    {
        Debug.Log("It is VR Player spawn-Start");
        SetVRLocalPlayerSetting();
        //InstantiateMimicVRHeadAndController();
        CmdInstantiateMimicVRHeadAndController();
    }
    else
    {
        Debug.Log("It is not vr Player its not isLocalPlayer");
        DisableSelectedMonobevaiourScripts();
    }
}
[Command]//This function have a problem
public void CmdInstantiateMimicVRHeadAndController() {
    Debug.Log("instantiateing the controller and head object");
    vrHeadCopyObj = (GameObject) Instantiate(vrHeadObjPrefab);
    vrRightCtrlCopyObj = (GameObject) Instantiate(vrRightCtrlPrefab);
    vrLeftCtrlCopyObj = (GameObject) Instantiate(vrLeftCtrlPrefab);

    // spawn the bullet on the clients
    NetworkServer.Spawn(vrHeadCopyObj);
    NetworkServer.Spawn(vrRightCtrlCopyObj);
    NetworkServer.Spawn(vrLeftCtrlCopyObj);
}


texts: How do I scale and rotate around different points in Libgdx?

texts:
I'm using a SpriteBatcher to rotate and scale a TextureRegion in libGDX. I'd like to rotate the texture around an origin outside of the region, but have the texture scaled around the region's center.

As far as I'm aware, this has to be performed in one action in the SpriteBatcher.draw() method. The region is scaled to the correct size, but scaled away from the origin.

I could compensate by adjusting the origin location, but is there a better method?


texts:
i'm making a game in libgdx and i have a question.

I have a Button from scene2d. If there is a touchDown event on this button, i want the touchUp event  only inside my button.

Now if i touchDown a button, then swipe outside my button, libgdx consider this like a touchUp.

I know that i can extend stage and work with it, the question is if there is a simple way to do this...


texts: Java - Lemmings - How to detect mouse over lemming

texts:
My first post on gamedev :) And my first go at game dev :D

To ease me in, I'm starting with a lemmings clone.

I have my lemmings moving about and already have a MouseAdapter for moving around the map with the mouse.

In order to detect when the mouse is over a lemming I thought the easiest way
would be to override the mouseMoved method. This would iterator over the lemmings and check if the mouse coords are in the lemmings rectangle. Is the normal way to do this?

I realised this wouldn't work for a lemming walking under/past the mouse cursor.


texts: Need to generate seamless gradient noise texture for water Shader

texts:
I need to generate something like this

for my water Shader, because on fly calculations are to expensive for mobile (https://docs.unity3d.com/Packages/com.unity.shadergraph@6.9/manual/Gradient-Noise-Node.html). The texture needs to be seamless. I currently clueless where and how to make this happen (especially about the seamless thing). Any help appreciated!


texts: XNA Skinning Sample - exporting from Blender recognize only first animation clip

texts:
(and sorry for my English)
I'm using animation components from XNA Skinning Sample. It works great but when I export a model from Blender, it does not recognize any other animation clips than the first one. So I have three animation clips, but XNA recognize only one. Also, when I looked up on Xml file of the model in Debug\Content\obj directory, there is only one animation clip, but when I check code directly from .fbx file, it seems to be alright.

Link to my model files:
https://skydrive.live.com/redir?resid=8480AF53198F0CF3!139

BIG Thanks in forward!


texts: SDL Player do something for 3 seconds then stop

texts:
I'll make my player respawn after 1 of his lives is taken, but I want him to be invincible for 2 or 3 seconds and not instadie again because he will be in the way of enemy bullets.

for (int i = 0; i < MAX_BULLETS; i++) if (enemyB[i]) {
    if(globalTime % 2 == 0)
        enemyB[i]->y -= enemyB[i]->dx;
    if (player->alive && (enemyB[i]->x > player->x && enemyB[i]->x < player->x + 97 && enemyB[i]->y == player->y-15))
    {
        if (player->invincible == false) {
            player->life -= 25;
            player->hbSprite++;
        }
        if (player->life <= 0) {
            player->invincible = true;
            player->lives--;
            player->life = 100;
            player->lifeSprite++;
            player->hbSprite = 0;
            if (player->lives <= 0) {
                player->alive = 0;
                player->hbSprite = 4;
                player->lifeSprite = 3;
            }
        }
        removenemyB(i);
    }
}

When I set player->invicible = true he's not taking dmg , but I need him to do that only for 2 or 3 seconds , help pls.


texts: Faster ways of rendering to a texture what is viewed by a camera in a given specific moment (Unity)

texts:
What I want to achieve is to render to a texture what is viewed by a camera in a given specific time or frame, and then stop rendering to the texture, delete the camera and stay with that texture for the rest of the gameplay.

So, I know how to set a Camera to continuously render to a texture in Unity: it's all about 1) to create a RenderTexture; 2) to specify such RenderTexture in the "Target Texture" field of the desired camera;  3) to assign the RenderTexture to a diffuse material; 4) to apply such material to a given object, let's say a plane.

It works great: all that is viewed by the camera is being rendered to the plane surface, but continuously (i.e. on the fly). This means that if, for instance, I delete the camera, the RenderTexture becomes a solid color. How can I save in the RenderTexture what the camera is viewing in a specific moment and then stop rendering to the texture?

EDIT: currently, I managed to achieve it by using the following code.

    RenderTexture rendText = RenderTexture.active;
    RenderTexture.active = mycam.targetTexture;
    mycam.Render();
    Texture2D cameraImage = new Texture2D(mycam.targetTexture.width, realcam.targetTexture.height, TextureFormat.RGB24, false);
    cameraImage.ReadPixels(new Rect(0, 0, mycam.targetTexture.width, realcam.targetTexture.height), 0, 0);
    cameraImage.Apply();
    RenderTexture.active = rendText;

However, for a RenderTexture with 1980x1080 (i.e. far from high quality), that piece of code takes around 50ms to perform the capture of the camera into a Texture2D. If I try it with a RenderTexture of 4096x4096 resolution, it takes around 160ms.

What is the correct way to accomplish this task for a more performant solution?


texts: Skeletal Animation: No initial bone rotation

texts:
I am currently trying to implement animations in my game. I am having an issue where the bones do not rotate properly.

In my program, I apply an inverse bind pose to each bone to move them to bone space. Then I recursively calculate the transformations for each bone for the keyframe.

The bone transformation looks like this:

bone.Transform = InverseRootGlobal * Global * bone.InversePose

InverseRootGlobal is the inverted root node transformation
Global is the recursively calculated transformation
bone.InversePose is the inverse pose matrix

It appears that all is correct apart from the bones initial rotation. When I move the bones to bone space, they loose their rotation from the bind pose and 'point up'. Here's what it looks like:

If it helps, I am using Assimp to import the data.

Thanks in advance.


texts: Can I develop games for mobile platforms in C++?

texts:
I have a good grasp in C++ and C and have also experience developing AAA game using C++.
Now, I'm shamelessly thinking to dive into mobile game development either in iOS or Android. Unfortunately, I don't know objective-C and java and neither have courage to learn it.
So, As above mentioned reason, Is there any possibility to do mobile development in C++ without using any single statement of JAVA and Objective-C ?


texts: What should I enter in Debug user and Release User in android export section in Godot?

texts:
I just want to export to android.

I have tried by adding my name, I got install error.


texts: Change the tilemap shown on stage in Flixel

texts:
I am building a simple platformer using Flixel, beginning with the source code from Flixel creator's EZPlatformer . I would like to adjust the level's tilemap when the player sprite enters/overlaps with a sprite representing a door. I use Flixel's built in function to track if the player overlaps the door sprite.

exits is a class level variable: public var exits:FlxGroup;

I call this function in the Update event to check for overlap:
FlxG.overlap(exits,player,UpdateScreen);

I successfully catch when they overlap, however when I try and load the new tilemap, the old one continues to show. I use this function to attempt to update the tilemap on the screen:

public function ChangeScreen():void
        {
            //load the screen and locations of sprites(e.g. player, exits) based on current screen
            switch(currentScreen)
            {
                case 1:
                    //load tilemap
                    level = new FlxTilemap();
                    level.loadMap(FlxTilemap.arrayToCSV(data1,40),FlxTilemap.ImgAuto,0,0,FlxTilemap.AUTO);
                    add(level);
                    break;
                case 2:
                    //load new tilemap
                    level = new FlxTilemap();
                    level.loadMap(FlxTilemap.arrayToCSV(data2,40),FlxTilemap.ImgAuto,0,0,FlxTilemap.AUTO);
                    add(level);
                    break;
            }
        }

I thought that I would need to first call remove on level to take it off the stage, and then call add on it, however, when I do that, the tilemap does not show up at all. What is the correct way to do this?


texts:
I'm doing a post-mortem on my game project, and this problem kept bugging me as my team couldn't solve it throughout.

So my game is a pure 2D top-down shooter built with Unity3D, with enemies constantly spawning and pathing to the player. The top-down shooter has narrow passages making it somewhat maze-like, and for now I can have anywhere from 1 to 20 enemies in-game at any point in time. I use a 2D pathfinding package which I assume to be sufficiently optimized.

Currently it performs terribly thanks to the pathfinding algorithm being called too many times.

What tricks can I use to reduce the number of calls?

PS. I know I could use NavMesh and all that built-in awesomeness. But the way we had set the game up denied us the use of those features :/


texts: What can I do with the 4th component of gl_Position?

texts:
When I set gl_Position I usually assign it such as gl_Position = vec4(in_position, 1.0) where in_position as a vector of three components representing a vertex of my model.

But looking up tutorials and such I cannot find anything explaining what the 4th component of the gl_Position vec4 is doing aside from making the vector big enough so matrix transformations can be applied to it.

Q: What can I do with the 4th component of gl_Position / what does it influence in the rendering process?


texts: WEBGL antialias false to pixel art low resolution

texts:
I know this issue maybe repeated and seems to be very common but I searched first and did not find anything concrete.

I am doing some test and playing around with pixijs. I created an stage 320x180 and I am rendering an sprite of 27x27 in a autodetected renderer (WEBGL always is selected) I am in a macos retina resolution (devicepixerate 4) the problem is I can not achieve having the sprite pixelated even setting antialias false in the renderer. I tested the same without pixijs but native canvas 2d context using drawImage and I could get what I wanted using some hacks like after every drawImage set context.imagesmoothingenabled to false and I have CSS file to canvas image-rendering: pixelated. With those I am having exactly what I want, but of course I would like to obtain the same using pixijs and WEBGL. Is it possible? Disable at all antialias in a WEBGL context? How we can deal with this to render pixel arts properly?

EDITED:
Using canvas 2d context native api

Using PixiJS webgl context.

Cheers.


texts:
I already know how to write games in C#, and I've learned the concepts behind network game programming, and created a working multiplayer game that works over LAN.

As an example, somebody runs the game server, which keeps track of the position of... say, a ball. Every so often, the server sends the current location and velocity of the ball to each of the connected clients. If something goes prevents the server from sending the stuff to the clients, the clients can still calculate the position of the ball by using the velocity, and hopefully stay closely enough synchronized with the server until it can resume sending again.

This is all very well and easy over LAN... but how do the clients connect to the server over the internet?