texts: How do you decide upon the price for a game?

texts:
I hope this is the right board for the question.

I have this idea for a game, programming Skills with C++ and a licensed Engine. I already made a prototype of the game as proof of concept and a few friends liked it so far.

I don't want to spoil it all, but it is a 2D Robotron Style Precision Shooter in an arena which is set in space.

All you do is beating waves of enemies and when you leveled up, you select a perk to enhance your ship. Examples are making weapons stronger, faster, making the ship more agile, different Weapons as Smartbombs, Mines etc.

Having different maps with this kind of game is quite difficult, since space does not have obstacles. All you can do is make different backgrounds and maybe asteroids etc. Another type of content could be to allow the user to gather some virtual money to unlock goodies that are available at wave 1.

So far for my idea. Now, would this alone already justify asking 5$ for a game? When I compare it for example to puppygames game "Titan Attacks", I say yes, since they do not have more features. On their website the game is 7$, on Steam 4$. Their Ultratron is also 7$, which is also a classic robotron style game. But it does not yield any special features imho ( it is fun nontheless :D ), but has a very adorable artstyle.

Nation Red, which is also an inspiring source for me (Robtron Style 3D Zombie Shooter, awesome game btw), costs 10$ on Steam but also has coop, local and online.

So, how do you estimate the price of your game that you just made so people don't feel ripped off and you still make profit after getting back the investment of licenses?


texts:
I have two objects. The head and tail of a future "grapple". The head and tail always point in the same direction. However, when I tried using scaled rectangles (that were bigger/smaller than the source rectangles) the rotations no longer worked, as in, the drawn head was no longer "attached" to the tail. (Without scaling them, this worked fine.)

The red sprites are without any rotation (Code below). The others are rotated about their respective "lower" origins (bottom center) (Rotation = 0)

So, the non-red sprites should be touching head to tail (the same way the red sprites are).

I have been fiddling with the code for a while... here is what I think you will need to see to help:

Initialization()
{
    Rectangle headSize = new Rectangle(0,0, 29, 100);
        Rectangle linkSize = new Rectangle(0,0, 29, 67);
        Rectangle tailSize = new Rectangle(0,0, 29, 53);

        Rectangle headSource = new Rectangle(0, 0, 29, 53);
        Rectangle linkSource = new Rectangle(0, 53, 29, 67);
        Rectangle tailSource = new Rectangle(0, 120, 29, 53);

        this.headSize = headSize;
        this.linkSize = linkSize;
        this.tailSize = tailSize;

        headSource = headsource;
        linkSource = linksource;
        tailSource = tailsource;

        chainHandle = new Link(new Rectangle((int)position.X,
                (int)position.Y,
                tailSize.Width,
                tailSize.Height),
                tailSource,
                0);

        chainHead = new Link(new Rectangle((int)position.X + tailSize.Width / 2 - headSize.Width / 2,
            (int)position.Y - headSize.Height,
            headSize.Width,
            headSize.Height),
            headSource,
            0);

}

    public Link(Rectangle rectangle, Rectangle sourceRect, float rotation)
    {
        TruePosition.X = rectangle.X;
        TruePosition.Y = rectangle.Y;

        Position = TruePosition;
        Rotation = rotation;

        scaledUpperOrigin = new Vector2(rectangle.Width / 2, 0);
        scaledLowerOrigin = new Vector2(rectangle.Width / 2, rectangle.Height);
        scaledCenterOrigin = new Vector2(rectangle.Width / 2, rectangle.Height / 2);

        upperOrigin = new Vector2(sourceRect.Width / 2, 0);
        lowerOrigin = new Vector2(sourceRect.Width / 2, sourceRect.Height);
        centerOrigin = new Vector2(sourceRect.Width / 2, sourceRect.Height / 2);

        dims = new Vector2(rectangle.Width, rectangle.Height);
    }

    public void Draw(SpriteBatch sb)
    {
        //debug purposes
        sb.Draw(chainAtlas, chainHead.GetRect(), headSource, Color.Red);
        sb.Draw(chainAtlas, chainHandle.GetRect(), tailSource, Color.Red);

        sb.Draw(
            chainAtlas,
            chainHead.GetRect(),
            headSource,
            Color.White,
            MathHelper.ToRadians(chainHead.Rotation),
            chainHandle.scaledLowerOrigin,
            SpriteEffects.None, 1);

        sb.Draw(
    chainAtlas,
        chainHandle.GetRect(),
            tailSource,
            Color.White,
            MathHelper.ToRadians(chainHandle.Rotation),
            chainHandle.scaledLowerOrigin,
            SpriteEffects.None,
            1);
}

Any ideas on how to fix this? I have tried using both original sized origins and scaled origins to no avail, as well as different points of origins.

If you have read this far, thank you for your time! Let me know if you see a fix.


texts: Ignore UI elements when clicking to move

texts:
I have a click to move character that uses a Nav Mesh Agent and I want to ignore clicks that are made on UI elements. For example, I don't want clicking around in my inventory to move my player to the target under the inventory. The relevant part of the move script is very simple.

if (Input.GetMouseButton(0) && !playerHealth.isDead)
{
    Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
    RaycastHit hit;

    if (Physics.Raycast(ray, out hit))
    {
        navMeshAgent.destination = hit.point;
    }
}

I would think that this is a common question raised among beginner developers or that it would be covered in beginner courses, but I can't seem to find the info I'm looking for when Googling around, so I'll ask it here.

So how do I get my Nav Mesh Agent to ignore clicks made on a particular UI element? How about ignoring clicks made to any and all UI elements? Thanks.


texts:
I am making a multiplayer game using Unity3D, similar to SecondLife (but focusing on a particular gameplay task). Users will be able to register/login directly in the game and their character will be spawned.
So far, I have made the back-end Rest-ful API to manage users. I am able to use login and register from the unity itself ( Using REST Calls e.g. www.myDomain.com/api/login ) but how do I spawn the characters accordingly?

Also, currently I am making a token based authentication system for the API ( much like Facebook, Twitter) as the API itself is state-less. Should I be storing the tokens in playerprefs?

I have gone through this tutorial but it doesn't seem to solve my problem.
Any kind of direction will help. Thank you.


texts: What is an alternative to scratch damage to solve combat deadlocking?

texts:
Scratch damage is a game mechanic whereby any successful attack always does some minimal amount of damage. This is often used in subtractive combat systems, where the defense is subtracted directly from the damage done by an attacker. Therefore, the target will always take some minimal damage.

The downside of such a system, for me at least, is that it's a hack. It takes a simple formula like Damage = Attack - Defense and turns it into a (slightly) more complex one: Damage = max(Attack - Defense, 1).

I also feel that it detracts from a player's skill in developing their character/etc. No matter how many defense bonuses they get, every attack will do some small damage. So why get your defense so high, if it won't mean anything?

Furthermore, this now encourages the use of larger numbers for Hp and damage, so that the scratch damage is truly negligable. After all, if the minimum damage is 1, and you only have 10 Hp, that's still 10% of your health. Even with 20 Hp, that's 5%. And I would rather avoid using larger numbers like that unless it's absolutely necessary.

However, there is one very important upside of scratch damage: it solves the deadlock problem.

Deadlock happens when neither side is able to do damage to the other. If you invest all of your resources into defense, and few into attack, then your character may not take damage, but they won't be able to deal very much either. Thus, you could come upon an encounter where neither side will be able to inflict damage, so battle continues forever. This is especially if you don't have random mechanics like critical hits (which I also hate).

At least with scratch damage, someone will eventually win. It may only be the one with the most Hp or highest number of attacks, but the battle will end.

So I like having a combat system where there will always be an outcome. But I don't like having scratch damage. What are my alternatives?

Alternatives that don't involve rolling random numbers; I want combat to be 100% deterministic. If the same battle is fought, the exact same outcome must happen.

If you want specifics on the gameplay, think in terms of turn-based combat, where battle can be automated (you design your forces, then pit them against others).


texts: What are patterns and how to use them? (Othello/Chess...)

texts:
I'm currently trying to make a Othello-playing program. My biggest concern at the moment is the evaluation function of game positions. Currently my evaluation function is quite primitive...move counting, looking for corner plays etc.

I tried to implement the evaluation functions of IAGO(1981) and BILL(1986).

I tried to read a bunch of papers, Michael Buro's stuff especially, but I failed horribly. It seems as I miss some fundamental knowledge. I neither get to understand how patterns work nor how to create them.

As far as I understand they are used to rate constellations of rows, columns, edges, 3x3 corners etc.

I'd highly appreciate if someone could provide me the following information:

What data structure has a pattern?
Given a certain game position how would I make use of this pattern to evaluate the situation?

I think if I get answers to those questions, I'll probably be able to understand the following aswell, but I'll mention them anyway.

How are patterns created? I saw that an approach is to assign static values to different squares of the game board, dependant of their current properties(color, stability). But then there is some iterative algorithm called.
So are patterns created on the fly e.g. while searching a tree? Or computed before and used like a mask?

I hope this question isn't too broad, but I got the impression that creation and use of patterns is some obvious common knowledge, that everyone does almost the same way, like use of alphabeta.


texts: How can I dynamically load the correct sprite from a sprite sheet?

texts:
I am making a simple card game in unity. The game is based on a standard 52-card pack, with identical backs for unique faces. In my particular game different cards are worth different values and have various special abilities. The game will have 52 cards on the table (on the draw position or in the face-down deck or in someone's hand) at all times, so this number won't change.

I thought that making a Card prefab and instantiating 52 of these manually would be a bad idea. Even doing it in code, I thought, would be a bit OTT, and that I should just instantiate visual cards when they are face-up to the player.

I have a sprite sheet of the 52 cards and the back, which is imported as a Sprite in multiple mode, sliced in to a grid containing all the cards needed to play the game.

The problem I now face is that, through my GameController script I want to generate a shuffled pack of cards, deal some to each player and then show those cards to a player. However, I am not sure of the best way, or even if it's possible, to do this dynamically with the sprite sheets as they are. For instance if I have the following:

private CardRank rank;
private CardSuite suite;
private GameObject visualCard; // the card in the scene

private void Start()
{
    this.rank = CardRank.Ace;
    this.suite = CardSuite.Spades;
}

This class would be instantiated by the game manager. I would have 52 of these in code.

Whenever I have to visually show a card in the scene, I would use a card prefab, which is essentially a game object with a SpriteRenderer on it. I would need to dynamically load the correct sprite for this object from the sprite sheet. Something like this:

SpriteRenderer spriteRenderer = this.visualCard.renderer as SpriteRenderer;
spriteRenderer.sprite = ...

The sliced sprites from the sprite sheet actually have names in the format AS (Ace of Spades), 7H (Seven of Hearts), etc - though this was a manual thing I did myself of course.

I have also tried various alternative solutions, including creating animations, having separate sprites not in a spritesheet and having an array of available sprites in an array with a specific index for each card, but none seem as elegant as trying to load the correct sprite at runtime, as I'm trying to.

So, how do I load a specific sprite from a spritesheet at runtime? I'm open to suggestions, even those that make me think differently about how to approach the problem.


texts: What should I focus on learning to get a job doing high level programming instead of low level programming?

texts:
I am in last year of college. I want to get a job in games industry as programmer but I don't want to do low-level programming. I want to do something AI and machine learning related. Am I in the wrong industry? Should I change focus to other jobs other than games industry?

By low level programming I mean, for example, connecting XNA and windows Forms or whatever. I mean I don't care about those kind of things, I want to work on higher level like doing fuzzy logic, how does the AI decide what to build in RTS and so on...


texts: Designing Diverse 2D Environment Tilesets

texts:
Is there an established methodology for designing diverse, quality 2d environment tilesets? I understand creating corners and borders and edges for different terrain types and materials, but I'm at a loss when considering how to make a terrain tileset that accomodates all types of concave edges and convex corners.

For example, the following Tilemap from Chrono Trigger:

They are able to basically create any shape they want with the surface tiles, and the rocky cliffs are perfectly matched.

How do you approach designing such a versatile tileset? Is there a specific set of required tiles that you need to design? Is there a basic terrain shape that should be designed that encompasses all these corners and types of tiles, that is later converted to a proper tileset?

Is it just a lot of artist work, or are there shortcuts?


texts:
I am attempting to transform the components of a mesh directly using a 4x4 matrix. This is working for the vertex positions, but it is not working for the normals (and probably not the tangents either).

Here is what I have:

// Transform vertex positions - Works like a charm!
vertices = mesh.vertices;
for (int i = 0; i < vertices.Length; ++i)
    vertices[i] = transform.MultiplyPoint(vertices[i]);

// Does not work, lighting is messed up on mesh
normals = mesh.normals;
for (int i = 0; i < normals.Length; ++i)
    normals[i] = transform.MultiplyVector(normals[i]).normalized;

// Tangents?? I really do not understand these guys
tangents = mesh.tangents;
for (int i = 0; i < tangents.Length; ++i) {
    Vector4 temp = transform.MultiplyVector(tangents[i]).normalized;
    temp.w = tangents[i].w;
    tangents[i] = temp;
}

Note: The input matrix converts from local to world space and is needed to combine multiple meshes together.


texts:
When testing bounding spheres as part of the collision detection process, I'm using this method:

    public static BoundingSphere TransformBoundingSphere(Matrix m, BoundingSphere b)
    {
        var center = b.Center;
        var edge = b.Center + Vector3.Right * b.Radius;

        var worldCenter = Vector3.Transform(center, m);
        var worldEdge = Vector3.Transform(edge, m);

        return new BoundingSphere(worldCenter, (worldEdge - worldCenter).Length());
    }

... to get a sphere in world coordinates (where m is a world matrix for the object encompassed by the original sphere).

(Yes, I'm aware that this relies on uniform scaling.)

This is obvious, reliable and easy, but is there a better way?


texts:
I want to use LWJGL to create a shader that all it does is change the color of the given texture. For example I tell it to draw the letter A using a sprite sheet then I can tell the shader to draw the letter in a certain color. How would you do something like this without needed to create different colored letter sprite sheets?

Task for the shader: Simply change all pixels to a certain color in the texture.
Input: Color , texture.
Output: it draws onto the screen the new colored texture.

How do i accomplish such a thing?


texts:
I'm curious to know if there is an XNA-like library for Java; that is, a library that

Handles the game loop - i.e. you just implement an existing method, and it will get called every frame.
Handles the rendering - i.e. you just tell it what to render, it will take care of displaying it to the monitor, hiding implementation details such as hardware acceleration.
Contains many useful methods for graphic, sound and user input options.

I'm interested in a library which supports both 2D and 3D options.


texts:
I've made a shader for a racing game in Unity that billboards a headlight glow effect (the lights are not actually light sources so I can't use lens flares). The quad with the glow texture is rotated to always face the camera but attenuated by the angle between the original normal and view direction so it only appears when facing the camera. I noticed when viewing from an angle that parts of the billboard were being occluded by the car so I set it to 'ZTest Always' to prevent this.

This all works fine, except there's a part where new cars are delivered by truck, and the lights are glowing through the truck door before it opens :-(

I tried re-enabling Z-testing and manually tweaking depth in the vertex shader after the MVP matrix multiply, but can't find a sweet spot that doesn't cause either one problem or the other at some point.

So I'm wondering if there's some way to have a moving occluder for occlusion culling in Unity. This way I could have the billboard occluded by the door until the point that it opens. The docs mention 'occlusion areas' for dynamic objects but this seems to refer to moving objects being occluded by static geometry, I'm not sure if it works the other way round.

Otherwise I guess it will have to be some kind of animation script that activates the lights at the exact moment the door opens...

EDIT - this sort of thing


texts: Composite collider 2D mysteriously adds x velocity to player rigidbody

texts:
As you can in the gif above there is an x velocity being set in the players rigidbody upon contact with the tilemap surface (Tilemap collider using composite). It was fine when I was using standalone colliders but now this happens.
Is this a bug or am I missing something. Help is much appreciated.
Unity ver. 2019.4.8f1


texts: cocos2d + sneakyinput joystick multitouch problem

texts:
I've added a joystick to my iOS game using the latest SneakyInput joystick code for cocos2d v3. It works well, but when a CCButton I have is pressed, the joystick touch event ends.

Based on my research, I've already set multitouch:

[CCDirector sharedDirector].view.multipleTouchEnabled = YES;

I've even tried setting multipleTouchEnabled for every button/joystick node, but still nothing works. Every time I touch the button, the joystick touchEnded method is called.

Here's the joystick code:

leftJoy = [[SneakyJoystickSkinnedBase alloc] init];
leftJoy.position = ccp(96,96);
leftJoy.backgroundSprite = [ColoredCircleSprite circleWithColor:[CCColor colorWithCcColor4b: ccc4(21, 21, 21, 127)] radius:64];
leftJoy.thumbSprite = [CCSprite spriteWithImageNamed:@"joystick.png"];
leftJoy.joystick = [[SneakyJoystick alloc] initWithRect:CGRectMake(0,0,128,128)];
leftJoy.joystick.multipleTouchEnabled = YES; // just testing
leftJoy.multipleTouchEnabled = YES; // just testing
[self addChild:leftJoy];

And my button code:

fire = [CCButton
                  buttonWithTitle:nil
                  spriteFrame:[CCSpriteFrame frameWithImageNamed:@"fire-enabled.png"]
                  highlightedSpriteFrame:[CCSpriteFrame frameWithImageNamed:@"fire-active.png"]
                  disabledSpriteFrame:[CCSpriteFrame frameWithImageNamed:@"fire.png"]];
fire.position = ccp(x,y);
fire.multipleTouchEnabled = YES; // testing
[fire setTarget:[World sharedWorld].player selector:@selector(fire:)];
[self addChild:fire];

The joystick works fine. Until the fire button is pressed.

I could redesign my buttons to use the sneakyinput button, but they work fine as-is except for this one issue.


texts: (C++, DirectX 11, UWP) - How do I update the ByteWidth of a VertexBuffer without recreating it?

texts:
I want to have one buffer used for all dynamic properties but the amount of vertices in this could vary from just a few for an interface to the whole scene. As such if it's becomes initialized with only let's say the below.

offset = 120; //example situation.
bd.ByteWidth = sizeof(VertexPositionColorTexture) * offset;

The above is 120 vertices, but if let's say the next time when I go to update. I need 160 vertices the buffer will only have space for 120 and will do one of the following.

Crash with an access exception.
Draw but it'll be missing those 40 excess vertices.

I update the Vertex Buffer by doing the following:

D3D11_MAPPED_SUBRESOURCE resource;
ZeroMemory(&resource, sizeof(D3D11_MAPPED_SUBRESOURCE));

Engine::context->Map(dynamic_interfaces_buffer.Get(), 0, D3D11_MAP_WRITE_DISCARD, 0, &resource);

memcpy(resource.pData, &vertsToDraw, sizeof(VertexPositionColorTexture) * offset);

Engine::context->Unmap(dynamic_interfaces_buffer.Get(), 0);

The "offset" value changes with what ever data ends up being present. I update the existing "vertsToDraw" data as needed.

So if the title didn't make sense. I'm looking to edit the ByteWidth value that what stored in the ByteWidth of the description when the buffer was originally created. My only solution so far was to set the buffer to the maximum size I feel I would ever need then set the VertsToDraw array size to that same value. However then when I update I only update with the needed amount. I'm not sure if that causes a performance issue by having a buffer with a byteWidth of "32 Bytes" * "36,000 Vertices". When in many cases I might only use a few 1000 or less.

Another thought I had if the above is the only way was to create multiple buffer of various sizes and use which ever one fits the situation the best.

E.g. if it's 3828 vertices use a 4000 pre defined vertices buffer or if it's 18348 vertices use a 19000 pre defined buffer.

But i'm up for any solution if there's a better way to go about this i'm a bit new to DirectX.


texts: How would you recommend I get started with ActionScript 3?

texts:
I wanted to make Flash games so I bought the book "Flash Games Development with AS3." I did the 'hello, world' program by trace and addChild (or something like that). But the problem was, instead of understanding what I was writing, I was just copying and pasting those lines of code. I felt it wouldn't work that way, and as the book had asked the learners to know at least some Java/Javascript, C#/C++, I didn't go any further.

Now, I want to start again (and yes, I still don't know Java or C programming). What would you recommend for me?

Thanks :)


texts: Data synchronization between master and slave servers

texts:
I am looking for a way to synchronize data between master data server (connected to a database) and slave game servers.

The master server should make a decisions about which data should be transferred to game servers, and implement data synchronization if required (for example, if data object is changed at master server, it should automatically send update packets to all required game servers).

I have some object classes to send: player data, map items data, ship data, item data, drone data and other game-related data.

I have my own implementation created with C# listeners (each game server has a structure at the master server which is listening for object changes in the master server's object arrays). But it looks quite complex and still has bottlenecks.

Do you have an experience of building such structures? What approaches or patterns can I use?


texts: How to load an AudioClip at runtime without the WWW class?

texts:
I am currently pulling a .wav file from an API. I would like to play it at run-time. Currently I need to save the .wav file to the persistentDataPath and then use the WWW class to load an audio clip using the file:// prefix. It works fine but the docs do mention that the WWW class is obsolete. What other options do I have if I want to avoid the obsolete method group?

I don't need to save the file to disk, I am simply doing that at the moment because its fairly safe to save it and then read it back out.


texts:
I'm trying to implement Collision detection using Rectangles for my game but can't seem to get it to work.

Bullets are updated when pressing space every frame so they move across the screen. Apparently so I've been told on here, the collisionbox moves with it as well. I'm getting this by using sprite.getBoundingBox() which sets a datafield Rectangle to this value for each instance.

I have two Arraylists, one holding instances of Monsters and one holding instances of Bullets. They all have collisionRectangles associated with them.

I'm calling the checkCollisions() method from my main render loop every frame as long as there's something in the bullets or monsters arraylist.

/*this handles collisions between bullets and enemies*/
public static void checkCollisions(){
    for (int i = 0; i < Main.currentBullets.size(); i++){
        for (int k = 0; k < Main.currentMonsters.size(); k++){
            if (Intersector.overlaps(Main.currentBullets.get(i).collisionBoxBullet,
                  Main.currentMonsters.get(k).collisionBoxMonster)){
                     System.out.println("Boom headshot");
                }
        }
    }

Why does it keep writing Boomheadshot to standard out even when its not colliding with an enemy?


texts: Android performance/issues with Corona SDK?

texts:
I know this is a fairly broad question. We are looking to develop a mobile game and want to use a multi-platform engine/SDK. We like what we see with Corona but in doing some reading, we are seeing a lot of references to poor performance on the 'droid platforms. I am unsure how much of this is still relevant? Many of the articles/posts/references/discussions vary in date from 18 months ago to earlier this year.

Is there a reason we should not pursue Corona if Android support is important to us?

The game is going to be 2D isometric view. Thanks!


texts: NullReferenceException Error For Respawning

texts:
I am making an infinite runner game, and I am having issues with killing and respawning the player. I have a coroutine setup on the GameMaster objec which is the respawn and on the player I have a method that calls that coroutine. But when ever the player hits an enemy I get a Null Reference Exception and I am not sure why this is happining.

Here is the entire error

NullReferenceException: Object reference not set to an instance of an object
Player.OnCollisionEnter2D (UnityEngine.Collision2D col) (at Assets/Script/Player.cs:32)

Here is the line that when I double click on the error it goes to. This line is on the player.

StartCoroutine(GetComponent<GameMaster>().RespawnPlayer());

This is the method that the above line is in. This method is on the player.

void OnCollisionEnter2D(Collision2D col)
{
    if (col.gameObject.tag == "Enemy")
    {
        Debug.Log("HIT");
        Destroy(col.gameObject);
        StartCoroutine(GetComponent<GameMaster>().RespawnPlayer());
    }
}

Here is the coroutine that the above method is trying to call. This method is on the GameMaster GameObject and this object never gets destoryed or setActive false.

public IEnumerator RespawnPlayer()
{
    player.GetComponent<SpriteRenderer>().enabled = false;
    player.GetComponent<BoxCollider2D>().enabled = false;
    player.GetComponent<movemnt>().enabled = false;
    yield return new WaitForSeconds(respawnDelay);
    adMenu.SetActive(true);
}

If anybody can give any suggestions that would be great!


texts: Can I post to Facebook with my own text from Unity on behalf of the user?

texts:
I'm using Facebook SDK for Unity 6.0 with FB.Feed.

I'm trying to post a link to the user's feed, text and link on his behalf.

So far I've managed to publish only a link and its details, the part where the user can write the post is left empty for him to fill.


texts: How to update different constant buffers for different vertices in vertex buffer?

texts:
Lets say I have vertices and indices for Box and Sphere and I put them into one vertex buffer.
But if I want to use different constant buffers for each of the figures, how would I do that?

As I understand I need to somehow say in VertexShader "Do those calculations for those vertices, and these calculations for these". But to my understanding, shaders don't work that way? Also I can't have two input layouts for each figure (it doesn't even make sense).
I've heard you are not suppose to do it that way these days, better to have different buffers for each figure, but still I want to try it.


texts:
Disclaimer: I'm not well versed in Game Dev best practices so this may be a trivial question.

I'm developing an iPhone game in which I have to store a user profile containing such information as scores for each level, latest level completed, etc. I've thought of a few ways to store this data but want to do it the "right" way (i.e. how it would be done by professionals) so am I on the right track with any of these methods or is there a better way:

Create a User class and serialize it using NSCoding/NSKeyedArchiver/etc. (This seems like overkill)
Store all that information with NSUserDefaults.
Some other method?


texts: Correct way/How to think to plan out "control/animation flow"?

texts:
So basically, a problem I've had in past attempt at making games (little playing around with stuff): how to do a correct, non-sloppy way of planning the flow of animations/control?

Let's take an example: you have a character, that can walk in the 4 cardinal directions, and can attack. It's that simple. Obviously, you can only walk in one direction at the same time, and let's assume you can attack when not moving in a direction only.

How would you take upon implementing this? Don't know if I'm clear, but what'd your thinking process go like?

I always end up with a huge mess of ifs and else ifs to get the animations to represent what is actually supposed to happen after moving in a direction,
ie. character after having moved up, will maintain it's upwards facing (will stay on the "up" animation);
Have the facing direction when moving be consistent: if you start walking left, it gets the left animation, correct. Then you start walking upwards at the same time, or downwards, and you'd like the animation to keep @ being left.
You start walking up, up animation. And as you start moving left or right after starting to move up, you maintain up animation.

See what I mean? I'll be here for clarifications on the question, sorry if confuse.

For 4 directions it'd not be that hard to do something "decently structured", but when things start adding up, it becomes so confuse!

Edit: Another thing I hadn't thought about: I was simply, upon WASD, altering the object's velocities, and handling all the animation stuff through what velocities were involved. Which leads to wrong things I had thought about, such as if I get pushed, it'd walk left stupidly instead of backing off facing the direction it had.

Another edit:  What I want is an answer of the sort: "First, for movement, you'd have a look at all the possible directions, and have an int or such indicating what's the current direction. Do a big switch, and inside of each direction, you'd have ifs for further x and y, but not z, because that's gonna be englobed in whatever. Then you should also have another control layer directly on the input handling to help filter unwanted actions or combinations, such as, you don't want to press A and D and have the velocities cancel each other out. For such, you'd have some further "status" for the object..." something of this kind! Thanks!


texts: 2D Shader for affecting lights based on y-distance

texts:
I've been struggling with this problem for a few weeks (mostly because I'm so new to shaders), but I have an angled camera for my 2D game that uses lights.

I saw this link about the '3D light simulation' and wondered how the shader responsible was written.

I'm in Godot, which uses its own shader language. I just need a way to compare the y-value's of the light source and the sprite.
I found

float d = (1.0 - (length(LIGHT_VEC)) + 1.0);
    float yoff = abs(VAR1.x * half_size_h / half_size_w);
    LIGHT_VEC.y += (half_size_h - VAR1.y - yoff) + z_offset;
    LIGHT = LIGHT;

which lowers the vector from the light to the fragment, but I couldn't get what I needed out of that.


texts: How to interact spheres with random walls

texts: I have a physics problem to deal with, I am asking here because a game developers often uses the efficient method. I have randomly distributed circles interacting to through Lennard-Jones potential or simply with a bounce back boundary condition to wall of random shape, as of know I am taking a V shaped wall. Please help me to understand an efficient algorithm the game developers uses for bounce back interaction.


texts: What measurement units are used in the return value of the getWidth method in the UnicodeFont class supplied by Slick2D?

texts:
I'm working on a small component for a game that essentially wraps the provided String so that it fits within the width of the provided rectangle. The rectangle is provided by the Slick2D library as well. I've assumed thus far that the width of that rectangle is in OpenGL units, but the distinction has been irrelevant in any way I've used Slick2D geometry so far.

Now, I'm using the UnicodeFont class and I'm not sure what units the return value of the getWidth method of that class is in. UnicodeFont.getWidth() returns an int value, so my initial inclination was to think it returned the value in pixels.

The Rectangle class supplied by Slick2D however, returns a float value. This leads me to believe that it is measuring the width using OpenGL coordinates, but I'm not sure.

So perhaps the community knows. Do the return values of both the Rectangle.getWidth() and the UnicodeFont.getWidth() methods use the same system of measurement?


texts: AI Agent realistic leap to a player in a MMO

texts:
In the last month I have been struggling with an issue, movement synchronization of a leap of an AI agent in a MMO. I know some theory and basic movement was not a problem with interpolation and stuff, the difficult part is implementing a leap move.

My current setup has a server and multiple clients connecting to it. The movement of the AI agent and its behaviour is computed on the server, the AI client receives position updates and interpolates between the current position and the position received from the server.

When the server decides that an AI has to attack, it sends an attack command to clients and, to make the thing more realistic, the clients stops their agents as soon as they receive the message and start an attack animation.

The important part now: during this attack animation, the agent quickly (0.6 s approx) translates (the translation is not in the animation) toward the targeted player. The client of that player then sends the landing position to the server which does some validation and hit checks and then resumes its behaviour computation sending new attack commands or position updates to clients.

This creates a very pleasing effect on the client of the player being attacked but may cause weird translations (due to the error in the position of the agents and the players) on other clients.

I tried predicting the "landing position" on the server but it's always somehow too wrong as it depends a lot on the target direction from the agent, and small changes in both the agent position and target position often lead to big errors.

Having a good look and feel of the leap on the client is imperative.

My questions are:

is there a better way to handle this in my case?
is there a good practice to follow in this that I am completely disregarding?


texts: libgdx - creating static HUD/widgets on screen

texts:
I'm having problems with creating static HUD/buttons on the game screen.
Currently my game has a character moving on the tiled map, with OrthographicCamera put on, everything works fine.
I wanted to add button on the screen:

...
Stage stage;
ImageButton imageButton;

@Override
public void create() {
        stage = new Stage(viewport);
        Texture texture = new Texture("bagbutton.png");
        Drawable drawable = new TextureRegionDrawable(new TextureRegion(texture));
        imageButton = new ImageButton(drawable);
        imageButton.setPosition(200, 200);
        imageButton.addListener(new ClickListener() {
            @Override
            public void clicked(InputEvent inputEvent, float x, float y) {
                System.out.println("clicked");
            }
        });

        Gdx.input.setInputProcessor(stage);
        stage.addActor(imageButton);
}
...

And then in render() method I got

stage.draw();

button appears, indeed, and it's even clickable. However, my player image (drawn by spritebatch.draw with texture) disappeared. Moreover, button is in the same position on map, and I'd like it to be somewhere on the bottom of the screen. It should be there statically, too, always in the same place, so when players moves, the button is always in the same place on screen. Next I'd like to make the same thing with some text and image, let's say on the top of screen. How to make it so?


texts: Information on seamless MMO server architecture

texts:
I'm looking for any material on seamless MMO servers! I do have a few articles in the "Massively Multiplayer Game Development" books and "Game Programming Gems 5." Has anyone experience on that topic or knows articles about that?

I'm interested in "high-level views" as well as implementations. This might become the topic of my master thesis and I would like to find out how hard it is to write such a system, before I actually start the thesis. Right now I haven't decided which language to use, I'm thinking about Java or Scala. Erlang could be a choice, but I've never worked with that.

Note: Basic requirement would be movement. Any other gamesystems are optional and give "bonus credit."

Now for what I mean with "seamless server": I want so set up a server cluster where every node controls some part of the game world, with static boundaries. Players can now move from one end of the world to the other without switching an instance or hitting some "teleporter". I think WoW does that. In my back-end however the player transitions from one server to the next.


texts: References about Game Engine Architecture in AAA Games

texts:
Last weeks I focused on game engine architecture and learned a lot about different approaches like component based, data driven, and so on. I used them in test applications and understand their intention but none of them looks like the holy grail.

So I wonder how major games in the industry ("AAA Games") solve different architecture problems. But I noticed that there are barely references about game engine architecture out there.

Do you know any resources of game engine architecture of major game titles like Battlefield, Call of Duty, Crysis, Skyrim, and so on? Doesn't matter if it is an article of a game developer or a wiki page or an entire book.

I read this related popular question: Good resources for learning about game architecture? But it is focused on learning books rather than approaches in the industry.

Hopefully the breadth of our community can carry together certain useful informations! Thanks a lot!

Edit: This question is focused but not restricted to first person games.


texts: Why is the timer not calling the function?

texts:
I am trying to call a function every 30 seconds. I have used this before without issues so I'm not sure why it isn't working now. Any ideas? Has something changed in 4.24 maybe?

.h I have tried both public and private

UFUNCTION()
void Ping();

And the .cpp I see both logs in the output so I know its getting there. Also the ensure passes. I have also tried GetWorld which is null in a UObject and GWorld which also works but has the same problem of the ping function not being called at all.

UE_LOG(LogTemp, Warning, TEXT("start ping"))
if (ensure(GEngine))
{
    UWorld* World = GEngine->GetWorldContexts()[0].World();
    UE_LOG(LogTemp, Warning, TEXT("start ping has gworld"))
    World->GetTimerManager().SetTimer(PingTimerHandle, this, &UGameJoltApi::Ping, 30, true, 30);
}

And here is the ping function. Its not called even once. I never see the log in the output.

UE_LOG(LogTemp, Warning, TEXT("ping"))
FString Url = URLBaseApi + URLSessions + "ping/?game_id=460364&username=" + Username + "&user_token=" + UserToken;

TSharedRef<IHttpRequest> Request = FHttpModule::Get().CreateRequest();
Request->SetVerb("POST");
Request->SetHeader("Content-Type", "application/json");
Request->SetURL(GenerateUrl(Url));
Request->OnProcessRequestComplete().BindUObject(this, &UGameJoltApi::OnStartSessionResponse);
Request->ProcessRequest();


texts:
Say for instance I have a puzzle with 3 switches that need to be in some configuration (say all on) in one room, that opens a door in another, with a load screen separating, so I can't link the switches directly to the door. My first thought was to create a singleton that stored the state of each "solution element" which in this case is the switches, but could be a correctly turned knob, ect. then a given "Puzzle Gate" like a locked door would check the required solution elements to decide it's own state, but I'm hesitant to use singletons for all of the commonly given reasons.

What alternatives do I have to singletons that would give me the same or similar control?


texts: Unity WheelCollider motorTorque acceleration with ps4 triggers

texts:
I'm fairly new to Unity and i'm struggling to find some answers. Every car script and wheelCollider tutorial I can find is based in the horizontal and vertical axis and that works great. But I'd like to move the car while holding a trigger and brake the car while holding another trigger (ps4 controller. Inputs are already mapped and working), but I need some help on that.

This is the part of the script that handles the acceleration:

 float motor = maxMotorTorque * Input.GetAxis("Vertical");
 foreach (AxleInfo axleInfo in axleInfos) {
     axleInfo.leftWheel.motorTorque  = motor;
     axleInfo.rightWheel.motorTorque = motor;
 }

Is there anyone that can point me in the right direction or possibly provide some example scripts?

Thanks in advance.


texts: HardonCollider Error: attempt to call method 'addRectangle' (a nil value)

texts:
I want to add collision detection mechanism to my game, which is written in love2d. As i do not want to implement my own algorithm, i have found a HardonCollider library to do the heavy lifting for me.

I have followed the example code of the library but got an error even with a basic setup.

local hc  = require "hardoncollider"

local hero
local collider

function on_collision(dt, shape_a, shape_b, mtv_x, mtv_y)

end

function love.load(arg)
    collider = hc(100, on_collision)
    hero = collider:addRectangle(30,30,16,16)
end

Running this code will throw the following error message:

PS C:\dev\love-0.10.0-win64> Error: main.lua:12: attempt to call method 'addRectangle' (a nil value)
stack traceback:
        main.lua:12: in function 'load'
        [string "boot.lua"]:437: in function
        [C]: in function 'xpcall'

I have been investigating the problem, but did not find any solutions nor anybody else who faced this error.


texts: MoveTowards giving two different results for same input - Unity

texts:
I have prefab and its hierarchy is as follows:

bird

-Outline

--mask

--filler

Now I am using this in Update to move the filler:

filler.gameObject.transform.position = Vector3.MoveTowards(
            filler.gameObject.transform.position,
            new Vector3(feedBar.gameObject.transform.position.x, -1.1f, filler.gameObject.transform.position.z),
            (1f / PlayerPrefs.GetFloat("timetofeedbird", 5)) * Time.deltaTime);

All the instantiated birds have movement in correct direction. But the last one has a movement in reverse direction.

Here is the GIF to explain the issue:

Any idea what the issue here?


texts: One big Instance or One instance for every moving entity?

texts:
I am creating a multiplayer JavaScript game with a PHP central server. Each user will be able to move around in a 3D world, with other users and NPCs. These NPCs will be controlled by the central server in PHP. Should I create one big world simulation PHP file that simulates all the NPCs in turn or a smaller controller that will be ran for each active NPC (on its own thread)? Each NPC has its own row on an SQL table and will be retrieved by the client to determine its position, state, etc.

Note: This is my first time creating a networked game, so if there is anything that I can do better, or a unique way of doing things that could work for this, feel free to comment


texts:
Is there some voxel frameworks or extensions for game engines like Unity?
I really need a system to dynamically generate voxel ruinable terrains.


texts: Why does clip space in OpenGL have 4 dimensions?

texts:
I will use this as a generic reference, but the more i browser online docs and books, the less i understand about this.

const float vertexPositions[] = {
    0.75f, 0.75f, 0.0f, 1.0f,
    0.75f, -0.75f, 0.0f, 1.0f,
    -0.75f, -0.75f, 0.0f, 1.0f,
};

in this online book there is an example about how to draw the first and classic hello world for OpenGL about making a triangle.

The vertex structure for the triangle is declared as stated in the code above.

The book, as all the other sources about this, stress the point that the Clip Space is a 4D structure that is used to basically decide what will be rasterized and rendered to the screen.

Here I have my questions:

i can't imagine something in 4D, i don't think that a human can do that, what is a 4D for this Clip space ?
the most human-readable doc that i have read speaks about a camera, which is just an abstraction over the clipping concept, and i get that, the problem is, why not using the concept of a camera in the first place which is a more familiar 3D structure? The only problem with the concept of a camera is that you need to define the prospective in other way and so you basically have to add another statement about what kind of camera you wish to have.
How i'm supposed to read this 0.75f, 0.75f, 0.0f, 1.0f ? All i get is that they are all float values and i get the meaning of the first 3 values, what does it mean the last one?


texts: How can I track both current and maximum values for a given statistic?

texts:
In my design I have several cases where I need to track both a max value and a current value (examples include Hit Points or Movement Points).
I could track these as separate variables:

int HitPointsMax;
int HitPointsCurrent;

or as a struct:

public struct HitPoints {
  public int Max;
  public int Current;
}

So my question: Is one of these preferable over the other, and why?

Is there some element of efficiency? A best-practice? Is there a better option?


texts:
I'm making a map viewer where you can specify where tiles go in a map and then see it on the screen, translate it, and zoom in and out.

Here's a picture showing the tiles used to make my example map

Here's the tiles connected together, more or less my desired result.

The problem is that at particular combinations of translations and zoom levels the spacing is off. Here's an example picture of the problem.

In order to arrange the tiles I'm using a Perspective projection matrix parametrized by the zoom level, a camera matrix which just translates the scene based the camera's 2d position, and finally each tile is translated using another matrix derived from its x and y position.

tile * camera * projection

How can I avoid this weird spacing issue at particular positions? I'm guessing this is some kind of floating point precision issue, but I'm not sure.

(for those interested, the tiles I'm using are from this collection)

EDIT:

I was using the following parameters for the standard openGL perspective projection matrix:

let near = 0.5;
let far = 1024.0;

let scale = zoom * near;
let top = scale;
let bottom = -top;
let right = aspect_ratio * scale;
let left = -right;

where aspect_ratio is the window width divided by the window height, (in pixels,) and zoom in the error case above was set to 8.0. I read some more on perspective projection and floating point errors but couldn't find anything sensible to change so I resorted to adjusting the parameters. Specifically I tried setting near to 1.0 and now I can't replicate the weird spacing. So I guess my problem is solved?

But this is a mysterious and unsatisfying answer, so I would still appreciate it if someone could explain what went wrong, and how I can avoid it in the future without fiddling with numbers until it "magically" works!

EDIT responding to amitp

Here's a screenshot from the same version as above (with near still set to 0.5), with the background set to red as suggested. This seems to indicate that it's something wrong with the tile layout, not image bleed.


texts: How to avoid "Blob-Systems" in an entity component system?

texts:
Currently I am facing the following problem:

I am trying to write a pong clone by using an entity component system (ECS). I wrote the "framework" all by myself. So there is a class which manages the entities with all the components. Then there are the component classes themselves. And last there are my systems which just get all the entities which have components which the system needs.

So for example my movement system looks for all entities which have a position component and a movement component. The position component just holds the position and the movement component holds the speed.

But the actual problem is my collision system. This class is like a logical blob. I have so much special cases in this class.

For example: My paddles can collide with the borders. If this happens their speed is set to zero. My ball can as well collide with the borders. But in this case its speed is just mirrored at the normal of the border so it is reflected. To do this I gave the ball an extra physics component which just tells: "Hey, this thing does not stop, it reflects." So actually, the physics component has no real data. It is an empty class which is just there to tell the system if an object reflects or stops.

Then there comes this: I want to render some particles when the ball collides with the paddles or the borders. So I think the ball has to get another component which tells the collision system to create particle on collision.
Then I want to have power ups which can collide with the paddles but not with the borders. If that happens the power-ups have to disappear. So I would need much more cases and components (to tell the system that some entities can only collide with certain others, bot not with all even if some others are actually able to collide, furthermore the collision system had to apply the power-ups to the paddles, etc., etc., etc.).

I see that the entity component system is a good thing because it is flexible and you do not have problems with inheritance. But I am totally stuck currently.

Am I thinking too complicated? How should I cope with this problem?

Sure, I have to create systems which are actually responsible for "post-collision", so the collision system only tells "Yes, we have a collision in the last frame" and then there is a bunch of "post-collision" systems which all require different (combinations of) components and then change the components. For example there would be a movement post-collision system which stops things which have to stop when collision happens. Then a physics post-collision-system which reflects things, etc.

But this does not seem to be a proper solution to me either, because for example:

My movement post-collision system would need entities which have a position component, a movement component and collision component. Then it would set the speed of the entity to zero.
The physics post-collision system would need entities which have a position component, a movement component, a collision component and a physics component. Then it would reflect the speed vector.

The problem is obvious: Movement post-collision needs entities which are a subset of the entities in physics post-collision system. So two post-collision systems would operate on the same data, the effect being: Although an entity has a physics component, it speed would be zero after a collision.

How are these problems solved in general in an entity component system? Are those problems even usual or am I doing something wrong? If yes, what and how should it be done instead?


texts: What architecture should I use to support extensions in my game?

texts:
What is the proper architecture for the game, that support extension modules, written in other languages?

I mean I have a simple game - written in Groovy (basically Java), heavily relying on Game object pattern (resources, configurations, part of game logic), which have a couple classes with certain logic.

I want to provide an ability to override that logic, using external modules written in another language (ideally I want to support any language). Also I want to have an ability to add additional logic.

What is the proper architecture for that?


texts:
Whats the advantage of using tilesets instead of importing the entire image itself ? Is it giving us some sort of advantage (in terms of memory maybe) ?
Also, how much of a disadvantage would it be to use whole image instead of tilesets ?


texts: How to generate seamless hexagonal textures

texts:
I'm doing a tactical game (X-Com / Fallout style) for fun.
I've decided to use a hexagonal map, but I'm having a graphic problem.

My current map display is HUD-like, with only the border of the map cells displayed, without any texture. It's simple and allows for display of different types of information by varying the color of the border. For example, the "danger view mode" displays the borders with a color going from green (no damage possible) to red (prob of damage > 90%).

Now, it's a bit hard to differentiate the kind of tile the player is on. I could put a plain color (green is grass, pale blue is water...), but this is going to limit the possibilities. Thus, I would like to display a texture on my tiles. Since the maps are generated, I can not use a picture for the whole map with the HUD over.

So, my question is: does anyone know how can I generate the seamless hexagonal textures (algo or plugin)?


texts: I am trying to create a basic game in Unreal Engine 4.8.1 and I wish to have it set in the Dubai, UAE but i cannot find a way that will successfully use terrain data i have obtained (NASA Shuttle RADAR 90m) to create a 1:1 scale map in unreal without creating huge world spikes. Does anyone know a method that can import the data without creating terrain spikes?


texts:
I am trying to understand the basics of normal mapping using this tutorial : http://ogldev.atspace.co.uk/www/tutorial26/tutorial26.html

What I don't get there is the following equation :
E1 = ( U1 - U0 ) * T + ( V1 - V0 ) * B

How do they came to this equation? This it out of nowhere for me. What is E1?
The tutorial say that E1 is one edge of the triangle. But I don't get it, in the equation E1 seems to be a real number, not a vector ( which an edge is supposed to be right? he have a x and y component ).


texts:
I am designing my first android game, and this is my first question on gamedev.stackexchange.

My MediaPlayer is null on my genymotion emulator, but is working fine on my actual android device. I have been looking for an answer to why the MediaPlayer only works on certain devices for a very long time now, but with no luck. Here is the code for the MediaPlayer, it runs in a service with a timer:

if (millisUntilFinishedRounded == 10000) { //TEN SECONDS
  MediaPlayer ten = MediaPlayer.create(TwentySeconds.this, R.raw.tenmoreseconds);
  try {
    ten.start();
  }catch(NullPointerException e){
    Log.v(TAG, "NULL");
  }
}

I am getting the log saying Null. I am lost at this point; why does it work on only some devices? Could this be a problem with the audio format or something?


texts:
I'm having an issue with interface block binding.

Example shader:

const char* vertexShader =
        "#version 330 core\n"
        "uniform globalMatrices"
        "{"
        "   mat4 vPMatrix;"
        "};"
        "layout(location = 0) in vec2 vPosition;"
        "layout(location = 1) in vec4 vColor;"
        "out vec4 color;"
        "void main()"
        "{"
        "   color = vColor;"
        "   gl_Position = vPMatrix * vec4(vPosition, 1.0, 1.0);"
        "}"

After creating the shader program i call functions:

    //this is done once per shader
    void BindShaderToMatrixBlock(unsigned int program)
    {
        GLuint globalUniformBlockIndex = glGetUniformBlockIndex(program, "globalMatrices");
        glUniformBlockBinding(program, globalUniformBlockIndex, 0);
    }
    //this is done once
    void BindUniformBlockMatrix()
    {
        glGenBuffers(1, &uniformBlockMatrix);
        glBindBuffer(GL_UNIFORM_BUFFER, uniformBlockMatrix);
        glBufferData(GL_UNIFORM_BUFFER, sizeof(glm::mat4), NULL, GL_DYNAMIC_DRAW);
        glBindBuffer(GL_UNIFORM_BUFFER, 0);
        glBindBufferRange(GL_UNIFORM_BUFFER, 0, uniformBlockMatrix, 0, sizeof(glm::mat4));
    }

And this is how i update the matrix:

inline void SetVPMatrix(const void* data)
{
    glBindBuffer(GL_UNIFORM_BUFFER, uniformBlockMatrix);
    glBufferSubData(GL_UNIFORM_BUFFER, 0, sizeof(glm::mat4), data);
}

I tried to debug as much as i could and confirmed that the data gets delivered to the uniform block but for some reason the matrix in the shader stays unchanged.


texts: Questions about “minecraft” game optimisation

texts:
I'm currently trying to do a basic "minecraft style" game. I know how difficult it is to create a game like this, that's why I juste want to do the base of a game like this. I did a class which creates one block face, another one which handles the creation of the whole block (All the faces), and a Chunk class which stores and renders all blocks.

My chunks are 16x1x16 sized (Just 1 layer of blocks). I did a first optimisation step : I removed all faces that aren't visibles (If two blocks are sided, I don't add the two sided faces). And another optimisation with the frustrum.

One chunk rendered Removing invisble faces

With one chunk rendered, framerates are good, but above 4-5 chunks rendered, framerates are becoming low. I don't know how to optimise more. I heard about VertexBuffers and IndexBuffers, but I don't know how to add them, because I have a lots of Blocks, in a lots of chunks. And maybe, in the future, how manage that if I want to destroy/place blocks ?

So my question is : How I can optimise the game ?

Thank you !

(Excuse my english, i'm a French guy eheh)


texts: Passing an OpenGL texture ID loaded in NDK back to java

texts:
Is it possible to load a texture using the NDK, but pass the result back to use in java.

I have used the code in the link above and it appears to load the png correctly and generates a texture ID without an error (the id is 0 before the loading function is called and non-zero afterwards).

Is it not allowed to mix opengl operations between C++ and java?

Thanks for your help
All the best,
Ash


texts: Collision detection not working in Phaser 3

texts:
I am new to phaser. So I started working on a game but I am stuck at implementing collision detection. I want to do it between a static group(dot) and a Sprite(obs).

function create(){

dot = this.physics.add.staticGroup(dotx, doty, 'dot');

dot.create(dotx, doty, 'dot');

obs = this.physics.add.sprite(obsX, obsY, 'obs');

this.physics.add.collider(obs, ball, alert, null, this);

}


texts:
i have a problem that i don't understand why is happenning and it's driving me mad.
I'm trying to code a script to put the player in the car by disabling the third person controller and then Transform.SetParent.
Here's the code:

  public ThirdPersonCharacterControl Controller;
  public GameObject Player;
  public GameObject Car;

 public void PutWheel()
    {
        if(isInteractive)
        {
            if(isCar)
            {
                PlacePlaceables();
                Controller.enabled = false;
                Player.transform.SetParent(Car);
            }
        }
    }

The error is:

Assets/Scripts/Player/Interactible.cs(361,34): error CS1502: The best overloaded method match for `UnityEngine.Transform.SetParent(UnityEngine.Transform)' has some invalid arguments

Assets/Scripts/Player/Interactible.cs(361,44): error CS1503: Argument `#1' cannot convert `UnityEngine.GameObject' expression to type `UnityEngine.Transform'

Why is that happening? It doesn't make sense to me because everything seems correct.


texts:
I read Gaffer's Fix Your Timestep article many years ago, and have since had the impression that game code should have a fixed timestep, with only non-gameplay related tasks outside of that in the main loop.

However, I recently reread the article, along with several others, and realized the emphasis is on physics. Which makes sense, but now I'm wondering if it only applies to physics.

What about games which don't use a real physics simulation? People talk about 60fps games, doesn't that imply a fixed timestep? What about multiplayer where you have regular updates to and from the server?

The only alternative I know of is variable rate with time delta, but that sounds like it wouldn't be any better, and less exact. What method is typically used?


texts:
I am developing a cross-platform game-engine with a friend, using C++, OpenGL 2 and 4, and some other low level API provided by the platform. Recently, we had an idea to adapt function definition at runtime. For example, Machine 1 provides only OpenGL 2; the engine will see that, and use only OpenGL 2 functions. Machine 2 provides OpenGl 4 ,as well, so the engine will use OpenGL 4, instead.

Our problem with this is the implementation, and how we should approach it. On first thought, we decided to use function pointers, but after trying for a bit, it led us into problems with the code. The code was hard to understand, and hard to both fix and extend. The second approach we thought about was to replace the .DLL (Windows) or .SO (Linux) file (or hot swapping). So far, we can not implement a working, stable build.

How do we enable the swapping of function definitions, at runtime?


texts: How to make the images appear in a specific location?

texts:
How can I draw a sprite in a specific location of the screen using native Android 2D graphics API?

The image should stay in the location specified.


texts: Animate sprite/texture position with VBO

texts:
I'm currently worlking on a renderer for my projects and I want animate a sprite on screen. I've got a spritesheet but I don't know what is the the best way to update the texture coordinates for each vertex.

Update vertices then update vertex buffer. (Heavy ?)
Send to the shader my texture coordinates (It is possible ?)
Don't use VBO ?

By the way, I've got this structure :
Object class with Geometry (Faces + Vertex + Buffer) and Material (Shader + other stuff ) properties, it is a good structure ?

Thanks!


texts:
A tutorial that I have followed had me collect and blit all of my sprites with the following lines:

allsprites = pygame.sprite.RenderPlain((l_sprites))
allsprites.draw()

At the moment, this is fine for me, as all of my sprites make use of the same base image.
However, I find myself in need of having various sprites animated, some changing, and some going to a basic colored rectangle.

My question is if this batch drawing method is still viable when all of my sprites are in flux.  My previous experience has been in straight C with SDL, and normally I would simply roll my own update loop.


texts: Ball vs 45-degree slope collision detection

texts:
I have a simple game in which the player moves a ball around. The ball bounces off of walls. Right now I have square walls(■) implemented: I use simple bounding-box collisions to check if the player will move into a wall when updating its x or y speed and if so, I multiply that speed with -1 to make them bounce.

However, I also want to implement triangular pieces(◢◣◤◥). To bounce back I believe one can simply use:

   newxspeed = -1*yspeed;
   newyspeed = -1*xspeed;

However, what I am having trouble with is the collision detection: When does the player hit the diagonal?


texts:
I want to optimize my colliders geometry, at the moment is composed by boxes (it's a tile based game) of the same dimensions, i want to remove the inner vertices to have, at the end, only the shell.
Does anyone knows or can point me out to the right direction/algorithm? The only way I can think about it's some kind of region growing with coordinates updating in a recursive way.


texts: Instantiated Object returns Null outside Start method

texts:
I'm attempting to access an instantiated 'goalTemp' GameObject from a different function inside the same script. I'm getting the information in the Start method, assigning the GameObject find/get component script code to a variable. When I'm printing the results outside the Start method, it returns null, even though the 'goal' variable is public.

void Start()
 {
     GameObject goalTemp = (GameObject)Instantiate(goal,respawnGoalLocation[CreateLevel.currentLevel-1],Quaternion.identity);
     goal = goalTemp.gameObject;
 }

public void Explode()
 {
     Debug.Log(goal);
     Instantiate(rockParticle, goal.transform.position, goal.transform.rotation);
     Instantiate(explosionParticle, goal.transform.position, goal.transform.rotation);
 }

What am I doing wrong here? Thanks for your time!


texts: Are there existing forums/QA sites specific to PS3 or Xbox360 development?

texts:
I'm wondering if there are existing forums, or sites similar to this one, that are targeted specifically to PS3 developers, or possibly, targeted specifically towards Xbox 360 developers?  Is all of this information proprietary, and therefore "secret," or do communities of developers for these platforms exist?

Thanks as always!


texts: How to make texture visible in unity from blender file?

texts:
I've imported a tree to Unity that I've made in blender, but the texture of the tree is not visible. Could you please tell me how to make that texture visible?

I am a beginer and I don't know how to actualy export it or what to select when exporting in blender. I only saved this 'maple' .blend file to my assets folder and that's it. I thought the tree would show up with the texture, but it didn't and I don't know what to do.


texts:
I am working on a simple game. It will have multiplayer over LAN, and I want to give the host the option to verify that players are not using modified clients (note that this will be disabled by default; this is more of a coding exercise). Both the client and host are identical.

Here's what I have so far:

1.) The host generates a random key.

2.) The host takes this key, combines it with the host IP address, and uses it to salt an MD5 hash of the important game files.

3.) The host then takes the generated key, and sends it in a packet to the client.

4.) The client takes this key, combines it the originating IP address of the packet, and uses it to salt an MD5 hash of the important game files.

5.) The client takes the hash and sends it back to the host.

6.) The host then checks the hash it receives from the client against the hash it generated. If they are unequal, it drops the connection.

Is this sufficient to deter most client modifications? I get that this check can be circumvented by using an unmodified client to generate the hash and sending it with a modified client; is there any way to prevent this?


texts: Is there a "box2d without physics" lib (only for collision detection)?

texts:
Box2d Collision detection algorithms are probably the best ones out there. Unfortunately, they are bundled together with a realistic physics engine that I don't need.

Is there an open source project out there that strips out the physics part of Box2D, or provides a similar functionality?


texts:
I have the following code from a tutorial and i am trying to compile it on a mac using g++/gcc however every time it complains about the native dialog but i am referencing the library correctly i think

#include<allegro5/allegro.h>
#include<allegro5/allegro_native_dialog.h>

int main()
{
ALLEGRO_DISPLAY *display;

if(al_init())
    al_show_native_message_box(NULL, NULL, "Error", "Could not initialize Allegro 5", NULL, ALLEGRO_MESSAGEBOX_ERROR);

display = al_create_display(800, 600);

if(!display)
    al_show_native_messagebox(NULL, NULL, "Error", "Could not create Allegro 5 display", NULL, ALLEGRO_MESSAGEBOX_ERROR);

al_destroy_display(display);

return 0;
}

The error i get is

main.cpp: In function ‘int _al_mangled_main()’:
main.cpp:17: error: ‘al_show_native_messagebox’ was not declared in this scope

And the command i use is

g++ -o main main.cpp -lallegro -lallegro_main -lallegro_native_dialog

I have also tried with

g++ -o main main.cpp -lallegro -lallegro_main -lallegro_dialog

Any help would be great.

Thanks


texts: Tilting towards turn direction (for a motorbike)

texts:
I have a motorbike which moves along based on a direction vector, I set its forward direction to the direction it's moving.

What I'd like to also do with it is have the motorcycle tilt in the direction it's turning, I haven't had much luck figuring this out though, any ideas?


texts: Changing State in PlayerControler from PlayerInput

texts:
In my player input I wanna change the the "State" of my player controller
but I have some trouble to do it

my player input is declared like that :

class ResistancePlayerInput extends PlayerInput within ResistancePlayerController
    config(ResistancePlayerInput);

and in my playerControler I have that :

class ResistancePlayerController extends GamePlayerController;

var name PreviousState;

DefaultProperties
{
    CameraClass = class 'ResistanceCamera' //Telling the player controller to use your custom camera script
    InputClass = class'ResistanceGame.ResistancePlayerInput'
    DefaultFOV = 90.f //Telling the player controller what the default field of view (FOV) should be
}

simulated event PostBeginPlay()
{
    Super.PostBeginPlay();
}

auto state Walking {
    event BeginState(name PreviousStateName) {
        Pawn.GroundSpeed = 200;
        `log("Player Walking");
    }
}

state Running extends Walking {
    event BeginState(name PreviousStateName) {
        Pawn.GroundSpeed = 350;
        `log("Player Running");
    }
}

state Sprinting extends Walking {
    event BeginState(name PreviousStateName) {
        Pawn.GroundSpeed = 800;
        `log("Player Sprinting");
    }
}

I have tried to use

PCOwner.GotoState(); and  ResistancePlayerController(PCOwner).GotoState(); but won't work.

I have also tried a simple GotoState, and nothing happen

how can I call GotoState for the PC Class from my player input ?


texts: Is a 10 meg 2048x2048 bitmap too big a size texture to use in an OpenGL game?

texts:
This is a speed question, I have a texture, which is 2048 per 2048, the texture is designed to run in big resolutions (1920x1080 for example).

The problem is, that the texture have a size of 10MB in bitmap, is too heavy, I don't know if that's a good size for load it in gl and use it in a game...

Is there any problem to use a 10MB texture in an OpenGL Game?


texts: Control how quickly 2D vehicle straightens out

texts:
I'm implementing vehicle movement in a 2D environment, where a vehicle consists of a front and a back "axle", both represented as 2D points. When the front axle moves, the back axle should follow in that direction, mimicking the way vehicles move. The way I have it right now looks like this:

After moving the front point A (white), I place B on the line between A and B such that a constant distance (the vehicle length) is kept. More accurately, I use the vector from A to B, normalize it, multiply it with the vehicle length, and add it to A, to get the new B. When searching for similar issues, I found this question's answer to come to the same technique.
As you can see, the resulting movement is quite recognizable as vehicle movement. The front also does not need to move as smoothly. Below I moved the front manually by dragging it around. As you can see, backwards movement also works perfectly:

I want to use this movement system as the back bone of a puzzle game, so its stiffness is actually an asset, since it is also quite predictable.
The only issue that I have is that it takes a good while for the vehicle to straighten out, by which I mean have the back come in line with the travel direction of the front. I'm looking for a way to control how quick this happens.
I have already played around with biasing/weighing the back point onto the line on which the front appears to be traveling, but that resulted in weird moving behavior for any other scenario than moving in a perfectly straight line. I also haven't been able to think of a different system that would inherently straighten out quicker.
So... I'm happy to try out any ideas that you might have!
Thanks!
Update 1: I've implemented the idea from @GaleRazorwind. This results in the back point moving away from the front point:


texts: Is it possible to program the entire logic and flow of a game without ever touching a graphic's engine?

texts: I'm not interested in rendering engines or level design, but I'm very interested in programming the AI that drives all of the characteristics of game play. I'm thinking of how the d20 system drives the rules behind D&D games. Is there a person that programs that logic, and is it possible to program almost all of an API without ever touching a graphic's engine? I'm a software engineer by trade (Java with some C# experience), so I'm looking to use those programming skills.


texts: UNITY : passing metalic map from Blender to Unity automatically?

texts:
I have .blend file contains very basic material shader structure (no fancy nodes), just add some textures (diffuse, normal, roughness, metallic etc) . When i imported the .blend file as prefab in unity (and copy all necessary texture/map to unity asset folder ) , the blender shader can pass albedo and normal maps (automatically) without problem. But it never be able to carry metallic map (or any other maps)
Right now i have to rebuild the metallic map within unity manually.
I'm just curious if unity can only recognize albedo and normal map from blender shader ? How about the other map ? How about metallic or smoothness/roughness etc ?


texts: How do I get an object to rotate in world space via RigidBody.AddTorque?

texts:
I'm getting really discouraged because I can't seem to figure how how to rotate my object via Rigidbody.AddTorque like it is on a figurative global turn table rather than a local turn table. Another way of describing it is that I want to c calculate a torque vector that will rotate the object's yaw and keep it upright regardless of its pitch without rolling it around. This is a problem for me because I want my player to remain upright without ending upside down because they were pitched and decided to turn.

Someone else had posted about the same problem on a different forum but he didn't receive much in the line of help, however he did provide this really helpful image describing the problem:

Notice how the left object is tilted and then rotating with respect to its own local coordinates but the one on the right is rotating with respect to the global coordinates instead of rolling around like the one on the left.

How can I achieve this? Is there something obvious I am overlooking or forgetting? Am I explaining it right?

EDIT:

In the following image the top half illustrates what I want while the bottom half is showing what is actually happening.
What I want is to be able to tilt the player's pitch and have them be able to rotate almost like a turret. I was able to accomplish this for demonstration purposes by first rotating the player and then pitching. Instead what I am getting is if the player tilts their pitch and then turns they start to bank, or in other words they start to roll.

My code looks something like this:

        _rigidBody.AddTorque(Vector3.up * _horizontal *
            RotateImpulse * Time.fixedDeltaTime, ForceMode.Impulse);

        _rigidBody.AddTorque(Vector3.right * _vertical *
            RotateImpulse * Time.fixedDeltaTime, ForceMode.Impulse);

I sincerely  appreciate you all offering to help me with  this.


texts: How to properly scale SCNNode so SCNPhysicsShape would be scaled for model too? It stays in old size

texts:
I wrote a script that would match all models in one size, no matter the original size of source model. So now I have these models fit precisely in the scene, but unfortunately when I'm adding SCNPhysicsBody to them (with SCNPhysicsShape) - their colliders (shapes) are old-sized. They do not match the current scale of a node.
How to fix this?


texts: Connecting 3d corridors created by procedural generation?

texts:
The 2d case is simple. You generate the segments. You find the intersections. Then you can easily outline the shape of the connecting joint in the 2d embedded graph.

However, in 3d or n-d with a whole new variety of directions (corridors from above and bellow), it is more complicated and I'd like to hear some advice.
The corridors themselves are simple. The challenge is the "connecting room" between them (you can imagine that room as convex hull of the red in blue dots). This is the goal here.

One way to overcome this, is using voxels and then leaving only the exterior of the connected corridors. This is not optimal however. Is there any simply way to generate the room in the center without complex binary operations?


texts:
For school I need to make a little game with UDK, the concept of the game is:

The player is the headguard, he will have some other guard (bots) who will follow him. Between the other guards and the player are some prisoners who need to evade the other guards.

It needs to look like this

My idea was to let the guard bots follow the player at a certain distance and let the prisoners bots in the middle try to evade the guard bots.
Now is the problem i'm new to Unreal Script and the school doesn't support me that well.

Untill now I have only was able to make the guard bots follow me.
I hope you guys can help me or make me something that will make this game work.

Here is the class i'm using to let te bots follow me:

class ChaseControllerAI extends AIController;

var Pawn player;
var float minimalDistance;
var float speed;
var float distanceToPlayer;
var vector selfToPlayer;

auto state Idle
{
    function BeginState(Name PreviousStateName)
    {

        Super.BeginState(PreviousStateName);
    }

    event SeePlayer(Pawn p)
    {

        player = p;
        GotoState('Chase');
    }
Begin:

       player = none;
       self.Pawn.Velocity.x = 0.0;
       self.Pawn.Velocity.Y = 0.0;
       self.Pawn.Velocity.Z = 0.0;
}
state Chase
{
    function BeginState(Name PreviousStateName)
    {

        Super.BeginState(PreviousStateName);
    }
    event PlayerOutOfReach()
    {
        `Log("ChaseControllerAI CHASE Player out of reach.");

        GotoState('Idle');
    }
//  class ChaseController extends AIController; CONTINUED
// State Chase (continued)
    event Tick(float deltaTime)
    {
       `Log("ChaseControllerAI in Event Tick.");

       selfToPlayer =  self.player.Location - self.Pawn.Location;
       distanceToPlayer = Abs(VSize(selfToPlayer));

       if (distanceToPlayer > minimalDistance)
       {
           PlayerOutOfReach();
       }
       else
       {
          self.Pawn.Velocity = Normal(selfToPlayer) * speed;
          //self.Pawn.Acceleration =    Normal(selfToPlayer) * speed;
          self.Pawn.SetRotation(rotator(selfToPlayer));
          self.Pawn.Move(self.Pawn.Velocity*0.001); // or *deltaTime
       }
    }
Begin:
     `Log("Current state Chase:Begin: " @GetStateName()@"");
}

defaultproperties
{
    bAdjustFromWalls=true;
    bIsPlayer= true;
    minimalDistance = 1024; //org 1024
    speed = 500;
}


texts: Is there any way to simply draw in 3D, just like you would draw with ShapeRenderer or SpriteBatch? All I want is to draw circles that are in x.y.z coordinates, so some circles are far away from view and some are closer. Also I would like to be able to rotate these circles.


texts: Rotate character 180 degrees determine direction

texts:
In my game it should be possible to rotate the character 180 degrees. I always want the character to rotate clockwise.

If the character is rotated 0 degrees and I press the rotate button, the character rotates clockwise to 180 degrees. However, if I know press the rotate button again, the character rotates to 0 degrees but doing so counterclockwise. How can I modify my code so that the character always rotates in a consistent direction?

One solution I've been thinking of is to do the rotaiton in steps like on first button press { 90, 180 } and on second {270, 0 }...

Any help would be greatly appreciated!

_currentTurnAroundAngle += TurnAroundSpeed*Time.deltaTime;

transform.rotation = Quaternion.Euler(0, Mathf.Lerp(transform.rotation.eulerAngles.y, _targetTurnAround, _currentTurnAroundAngle), 0);

if (transform.rotation.eulerAngles.y >= (_targetTurnAround - 0.1f) && transform.rotation.eulerAngles.y <= (_targetTurnAround + 0.1f))
{
    _currentTurnAroundAngle = 0;
    transform.rotation = Quaternion.Euler(0, _targetTurnAround, 0);
    _targetTurnAround = (_targetTurnAround == 0 ? 180 : 0);
    _isTurning = false;
}


texts: OpenGL es glDrawTexfOES() 2D texture is totaly black no color

texts:
First of all I know this is a duplicated question and I check out another questions but didn't helped! I'm trying to convert my android game from canvas system to the GL10. After lots of googling I decided to do that for performans. Anyway I tryed to build a class that loads and draws textures. The problem is textures showing up whole black over my blue screen.
I'm not sure If I can draw texture without creating any mesh or something like that but this is what I'm trying to do. I'm only trying to draw 2D texture on their own sizes so I think no mesh needed. Here are my codes:

  onSurfaceCreated

    @Override
    public void onSurfaceCreated(GL10 gl, EGLConfig config) {
        gl.glClearColor(0.0f, 0.0f, 1.0f, 0.2f);
        gl.glClearDepthf(1.0f);
        gl.glViewport(0, 0, 800,  480);

        gl.glShadeModel(GL10.GL_SMOOTH);
        gl.glEnable(GL10.GL_DEPTH_TEST);
        gl.glEnable(GL10.GL_TEXTURE_2D);
        gl.glDepthFunc(GL10.GL_LEQUAL);
        gl.glMatrixMode(GL10.GL_PROJECTION);
        gl.glHint(GL10.GL_PERSPECTIVE_CORRECTION_HINT, GL10.GL_NICEST);
        //gl.glHint(GL10.GL_PERSPECTIVE_CORRECTION_HINT, GL10.GL_FASTEST);
        gl.glLoadIdentity();
        // This is the class where I load and draw my textures.
        textureStorage = new TextureStorage(gl);
        //I'm loading a texture.      **CODE A TEXTURE LOADER**
        bgNightID  = textureStorage.Load(BitmapFactory.decodeResource(context.getResources(),R.drawable.bg_game));
        //This is where I load my units variables. Nothing to do with it.
        RenderingFunctions.InitUnits(this);
    }

  onDrawFrame

@Override
public void onDrawFrame(GL10 gl) {
    gl.glClear(GL10.GL_COLOR_BUFFER_BIT | GL10.GL_DEPTH_BUFFER_BIT);
    gl.glLoadIdentity();
    //gl.glTranslatef(0, 0, -4);
        **CODE B DRAWING**
        // bgNightID is the ID of texture was loaded.
        textureStorage.DrawTexture(bgNightID, 50,50,0,(short)4000,(short)638);
        // Drawing background right here which is shows up black.
}

  CODE A  TEXTURE LOADER

public int glLoad( Bitmap bitmap ){
    if ( gl == null ){
        Log.e(TAG, "Failed to load resource.  Context/GL is NULL");return -1;
    }
    int textureName = -1;
    gl.glGenTextures(1, TexIDStorage, 0);
    textureName = TexIDStorage[0];

    Log.d(TAG, "Generated texture: " + textureName);
    gl.glBindTexture(GL10.GL_TEXTURE_2D, textureName);

    gl.glTexParameterf(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_MIN_FILTER, GL10.GL_LINEAR);
    gl.glTexParameterf(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_MAG_FILTER, GL10.GL_LINEAR);
    //gl.glTexParameterf(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_MIN_FILTER, GL10.GL_NEAREST);
    gl.glTexParameterf(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_WRAP_S, GL10.GL_CLAMP_TO_EDGE);
    gl.glTexParameterf(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_WRAP_T, GL10.GL_CLAMP_TO_EDGE);
    gl.glTexEnvf(GL10.GL_TEXTURE_ENV, GL10.GL_TEXTURE_ENV_MODE, GL10.GL_REPLACE);

    GLUtils.texImage2D(GL10.GL_TEXTURE_2D, 0, bitmap, 0);

    int error = gl.glGetError();
    if (error != GL10.GL_NO_ERROR){
        Log.e(TAG, "GL Texture Load Error: " + error);
    }else
        Log.d(TAG, "Loaded texture: " + textureName);
    return textureName;
}

  CODE B DRAWING

public void DrawTexture(int TexutreID, float X, float Y, float Z, short Width, short Height){
    gl.glClear(GL10.GL_COLOR_BUFFER_BIT | GL10.GL_DEPTH_BUFFER_BIT);
    //gl.glColor4f(1.0f, 1.0f, 1.0f, 0.5f);
    gl.glBindTexture(GL10.GL_TEXTURE_2D, TexIDStorage[TexutreID]);
    ((GL11Ext) gl).glDrawTexfOES(X, Y, Z, Width, Height);
}

I'm totaly new to GL10 and can't figure out what is the problem and what is it I'm missing. So if anyone can help me that would be great. Thank you for givim time!


texts: In Unity, my mesh is not rendering when huge (scale of 1400000)

texts: Any help/tips? This is for a space game and I really want realistic measures. The user WILL get really close to the sun. Any tips with dealing this? I can see the whole "Corona" but not the big sphere at the center


texts: very simple math destination and speed calculation

texts:
My player goes to (destinationX, destinationY)

His position is: (x,y)

and the player has an update event

function update() {
 this.x = this.x + dx;
 this.y = this.y + dy;
}

what is the formula for dx and dy ?

dx = (destinationX-this.player.x)/this.speed;
dz = (destinationZ-this.player.z)/this.speed;

is "almost" good: it goes to the good direction, but problem is his speed.
It takes the same time to go from (0,0) to (10,10) than from (0,0) to (1000,1000)


texts: How can I use Find to find part of a GameObject name?

texts:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class NaviMove : MonoBehaviour
{
    public GameObject target;
    public ObjectsManipulation om;
    public float moveSpeed = 1f;
    public float maxFallSpeed = 2f;
    public float rotationSpeed = 1f;
    public GameObject player;

    private Rigidbody rigid;
    private Waypoints waypoints;
    private Camera navicam;
    private GameObject ground;
    private float distance;

    void Awake()
    {
        rigid = GetComponent<Rigidbody>();  //get the rigidbody that attached to the object
    }
    void Start()
    {
        waypoints = GetComponent<Waypoints>();
        navicam = GetComponent<Camera>();
        ground = GameObject.Find("Floor");
    }
    void FixedUpdate()  //physic should be done in FixedUpdate not Update
    {
        if (DetectInteractable.detected == true && ItemAction.move == true)
        {
            transform.parent = null;  //disconnect the object for it's parent
            om.stopRotation = true;
            rigid.isKinematic = false;
        }
        if (om.stopRotation == true && ItemAction.move == true)
        {
            distance = Vector3.Distance(transform.position, ground.transform.position);
            if (distance > 1)
            {
                navicam.enabled = true;
                navicam.transform.rotation = transform.rotation;
                navicam.transform.forward = transform.forward;
                if (rigid.velocity.sqrMagnitude > maxFallSpeed) //check if it's falling to fast
                {
                    rigid.velocity *= 0.01f; // falling to fast, so reduce speed,  you may want to play around with this number.
                }
                else // if not falling to fast add force to make it fall faster
                {
                    rigid.AddForce(Vector3.down * moveSpeed);
                }
            }
            else
            {
                ItemAction.move = false;
                rigid.isKinematic = true;
                waypoints.enabled = true;
                player.SetActive(false);
            }
        }
    }

    private void OnCollisionEnter(Collision collision)
    {
        if (collision.transform.name.Contains("Floor"))
        {

        }
    }
}

The problem is that ground always null:

ground = GameObject.Find("Floor");

There is no object name Floor but there is an object that it's name part of it contains floor. So it was working fine when I used it inside the OnCollisionEnter I could use Contains.

But now I want to check the distance between the transform that fall down and the ground/floor. Maybe there is a better way to do it maybe using also the OnCollisionEnter ?

The goal is not just making the transform falling down and collid the floor I want the transform to stop falling a bit before the floor like distance 1 or even 3 before colliding with the floor. And I don't want to get each time the object full name since I will use this script in other places.


texts:
Hello I am trying to understand matrix operations behind OpenGL and I have some questions.

1- When we first create a simple window using glut and opengl, we use such a command below to draw a simple triangle.

glBegin(GL_TRIANGLE);
glVertex3f(0.25, 0.25, 0.0); // coordinate 1
glVertex3f(0.75, 0.25, 0.0);
glVertex3f(0.75, 0.75, 0.0); // coordinate 3
glEnd();

Does this drawing take plece in object coordinate sytem or at other coordinate sytems ?

Assume that, I applied a transformation using glTranslate(), so this translation manipulates the modelview matrix. Now if I apply the command above again

glBegin(GL_TRIANGLE);
glVertex3f(0.25, 0.25, 0.0); // coordinate 1
glVertex3f(0.75, 0.25, 0.0);
glVertex3f(0.75, 0.75, 0.0); // coordinate 3
glEnd();

Is this drawing still done in object space coordinates and transformed to eye space using modelview matrix ?

edit:

at first when you use command glvertex(0,0,0) , you draw a point at (0,0,0) in both object, world and eye coordinates it is (0,0,0). of course this is done after modelview matrix is cleared using gloadidentity().

now apply the command gltranslate(2,0,0) , and again use command glvertex(1,0,0), now you draw a point at (3,0,0) . this is good but which coordinate system (3,0,0) is represented in ? do you draw in eye coordinates (3,0,0) ?

Is my thought below true ?

I think that glvertex(1,0,0) draws a point in object coordinate (1,0,0) , and since model view 4x4 matrix now is not an identity but has a "2" at the first row and fourt column because we applied gltranslate(). if we multiply our new modelview matrix with (1,0,0) in obj. coordinates, now we have (3,0,0) in eye coordinates .


texts: How do I avoid causing more collisions, when resolving multiple AABB collisions?

texts:
I have a lot of AABB bouncing on the screen. Doing collision/response between 2 AABB is fairly easy, but how do you handle this when you can be pulling AABB's apart but making them getting into another AABB? I mean something like this scenario:

We have 3 AABBs.
We check if first one collides with the other two. No collision is found.
We check if second collides agains the third (we don't need to recheck agains first). We find a collision, we separate second AABB form third but it intersects now with first one.

This will produce a bad response/collision detection. How do you handle this chained collisions?

Edit: I forgot to say that all aabb are dynamics objects. I mean, they move.


texts:
I'm trying to make a game with real time strategy elements, where you can build several different buildings.

The problem is that I can't seem to make the buildings stop overlapping. That is too say, if try to build while my mouse is hovering over a building, it won't build, which is good.

But the moment that my mouse is no longer over a building, I can build again. And since the buildings have a centered origin, the building is build around the coordinates where the mouse is. This causes overlap between buildings, which is bad.

I have the following code in a step event of a control object:

if (mouse_check_button_pressed(mb_left)) {
  if (!position_meeting(mouse_x, mouse_y, all)) {
      instance_create(mouse_x, mouse_y, obj_shed);
      player_money -= 100;
  }
}

Any help would be greatly appreciated.

EDIT: The code now follows the suggestions of Despicable and looks as follows:

var object, width, height;
object = obj_shed; //Change to your desired object
w = object.sprite_width;
h = object.sprite_height;

if (mouse_check_button_pressed(mb_left)) {
  if (!collision_rectangle(mouse_x-w/2,mouse_x+w/2,mouse_y-h/2,mouse_y+h/2,all,0,1)){
    instance_create(mouse_x,mouse_y,obj_shed);
    player_money -= 100;
  }
}

However, w and h give an error, so now i need to find a way how to get the width and heigh of an object that is not the calling instance (because the calling instance is a control object, in which is code is situated)

EDIT: Solution

I was able to change the solution so that the buildings won't overlap, even if the buildings aren't circular:

In the control object, in the step event, write the following:

if (mouse_check_button_pressed(mb_left)) {
      instance_create(mouse_x, mouse_y, obj_shed);
}

And in the create event of your building (shed in my case):

if (!place_meeting(mouse_x, mouse_y, all)) {
      global.player_money -= 100;
}
else {
    instance_destroy();
}

So on creation of the building, it checks if there is a collision. If so, it destroys itself. If not, it stays there and deducts the cost of the building. This works with any shape of building.


texts: How to accept microtransactions with a desktop application?

texts: I want to implement microtransactions into a desktop application I'm working on, but the microtransaction services I know of are all targeted primarilly towards Flash or smartphones. Are there any that explictly support desktop applications?


texts:
For a 2d side scrolling game made in Java, should I make a sprite sheet for my character walking left and for walking right, or should I just do the one, and flip it when it loads?

Also, the way I've been doing it, both left and right would be in the same image file, if that makes any difference.


texts: Why do I get glitchy graphics when drawing scene with scene2D?

texts:
I'm trying to display a simple text for a menu UI using scene2D, but for some reason nothing is being displayed here. The screen displays pure black.

public class ScreenMenu implements Screen {

MyGame myGame;
SpriteBatch batch;
Stage stage;
Label labelNewGame, labelContinue, labelCredits;

public ScreenMenu(MyGame myGame) {
    this.myGame = myGame;
}

@Override
public void show() {
    init();
    BitmapFont font = initFont();
    initLabels(font);
    initStage();
}

private void init() {
    batch = new SpriteBatch();
}

private BitmapFont initFont() {
    return new FontLoader().getMichroma();
}

private void initLabels(BitmapFont font) {
    Label.LabelStyle labelStyle = new Label.LabelStyle(font, Color.WHITE);
    labelNewGame = new Label("New Game", labelStyle);
    labelContinue = new Label("Continue", labelStyle);
    labelCredits = new Label("Credits", labelStyle);
}

private void initStage() {
    stage = new Stage(new ScreenViewport());
    Gdx.input.setInputProcessor(stage);
    stage.addActor(labelNewGame);
}

@Override
public void render(float delta) {
    GlHelper.clearScreen();
    stage.act(delta);
    stage.draw();
}

@Override
public void resize(int width, int height) {
    stage.getViewport().update(width, height, true);
}

@Override
public void pause() {
}

@Override
public void resume() {
}

@Override
public void hide() {
    dispose();
}

@Override
public void dispose() {
    myGame.dispose();
    batch.dispose();
    stage.dispose();
}
}

The following class contains the clearScreen function. If I don't run it, the entire screen becomes super glitchy, but I can see the New Game text.

public class GlHelper {

public static void clearScreen() {
    Gdx.gl.glClearColor(0, 0, 0, 0);
    Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
}

public static void clearScreen(float red, float green, float blue, float alpha) {
    Gdx.gl.glClearColor(red, green, blue, alpha);
    Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
}
}


texts:
So in my program, I currently know how much Experience a player has. I was using this formula to figure out what level the Player was:

function calcLevel($XP,$const){
     $L = sqrt($XP)*$const;
     return floor($L+1);
}

Then I wanted to figure out what Percentage of the way the player was to the next level, so I needed to figure out how much Experience they needed to get to that point. I thought this would work:

function xpNeeded($L,$const){
    $XP = pow($L,2)/$const;
    return $XP;
}

I would also need to know how much previous Experience the player had earned in other levels so I could calculate the percentage based on the Experience earned at the current level only:

function prevXP($L,$const){
    $XP = 0;
    for($i=1;$i<$L;$i++){
        $XP = $XP + xpNeeded($i,$const);
    }
    return $XP;
}

This all made sense to me, but the calculations are a bit off.

For instance, using Level 2, and Constant of .1:

$const = .1;
$lvl = 2;
$a = xpNeeded($lvl,$const); //returns 40
$b = prevXP($lvl,$const); //returns 10
$c = $a+$b; //50
calcLevel($c,$const) //returns 1, should return 2

I can't really tell where my calculations have gone wrong, obviously, it is in the xpNeeded function, I just do not know what I did wrong.