texts: FPS Crosshair, Should it be drawn on center of the screen or to the forward of bullet spawn point?

texts:
so my question is where to draw crosshair? I have some things in my mind like:

1): Draw it on the center of camera(which will stays on the center of screen always), but as my gun is little lower to the camera so my bullets will always hit little lower to the target, but at the same time every FPS draws crosshair on the center(correct me if I am wrong).

2): Draw it to the forward of bullet spawn point so bullets will always be on target. But this also has some issues, player can't just be standing freezed it will move a little so did the gun and in turn crosshair will also move, but I haven't seen any FPS with crosshair moving while player is standing to shoot or even walking plus this will also make the game tough or annoying.

3): Draw the crosshair little lower to the camera(camera.y - difference between camera.y and spawnPoint.y) so the crosshair and bullet spawn point are aligned, but won't it look little weird to have a crosshair little lower to the center of screen.

I had read Shooting the bullet out of the gun instead of the camera, yet keeping it accurate with respect to the reticle

What I get from this is that raycast from camera and fire the bullet in direction where the raycast hits, but the bullet will not be going out from the forward of spawn point and this will look bad. The guy explains something with the animation but I didn't get that point. In GTA V's FPS mode crosshair is being drawn in the center, hands and gun are little low from center so there is no way that gun will hit exactly at the center of crosshair but it does hit and we can see that bullet(not actually bullet, some kind of ray) is getting fired from muzzle of the gun, how do they do it? I am sure there is some kind of trick for that.

I don't know what to do or there are other ways of doing this, any help would be much much appreciated.

My question is similar to the given link but it don't have much information so I am not trying to be duplicate here I am just looking for some more information

Thanks for reading this


texts: In theory, would an erosion algorithm compute faster on a GPU than CPU?

texts: I'm planning to port an erosion algorithm from CPU to GPU, in theory, will it be faster or would it be better to multi-thread it on the CPU? The algorithm has quite a lot of if statements and loops with non-constant amount of iterations so it's going to be a lot of branching.


texts: How to calculate the sound volume for the left ear and right ear based on the object position & velocity, player position & forward vector? (3D sound)

texts:
Please assume:

Minimum distance for 3D volume = 1.0;
Maximum distance for 3D volume = 100.0;

This is the declaration of the function:

An object can be a ball moving closer to the player.

void CalculateSoundVolume(Vec3 objectPosition,
                          Vec3 objectVelocity,
                          Vec3 userHead,
                          Vec3 userFoward,
                          float& leftEarVolume,
                          float& rightEarVolume)
{

}


texts:
I'm working on a game that is going to involve gasp hexagons.

At present, I have a hexagon image that I am using (all sides are the same length...it fits into a 50px by 50px image).

I am somewhat new to C# and really new to XNA, but is there some sort of easy method that I can call rather than doing a convoluted if statement based on points and angles?


texts: What do you call the logic gates visual programming of PS4 Dreams?

texts:
The PlayStation 4's Dreams app has a visual programming framework made up of sensors (detect touch, a person etc.), logic gates (AND, NOT, splitters etc.), wires, and action outputs (move somewhere, execute keyframe, teleport etc.). Through these flows energy which is usually a value between (presumably) 0.0 to 1.0. This in turn is used to create full games logic, movies and more.

Is there a name for this type of programming UI? I can think of a general "logic gates" programming or so, but maybe there's something more specific. Thanks!


texts: Cannot create a neutral unit with a trigger

texts:
I've been playing around with the starcraft UMS (Use map settings) for a while and usually i figure things out pretty quickly when im stuck. Alas not this time.

I'm trying to place a neutral unit (player 12) using a trigger. It refuses to work.
I'm using Scmdraft 2.0 as my editor (but i cant get it to work in other editors either)
(all neutral units placed before the game starts are visible and all other triggers work fine. Also i created a text msg and it does displays it in-game so the trigger triggers )

For testing I created a trigger that looks like this:

Player: neutral (i tried neutral players player 1 and all players as well)
Condition:
-always
Action:
-Create *1 Terran Medic* at '*location 022*' for *Neutral* (also tried neutral players)

When I start the game nothing happens.

Here is what I tried:

I tried placing a start location for neutral player (player 12)
I tried changing the owner under map properties of player 12 to neutral and computer from unused which was the default.

Although it seems like it should be a common enough problem, I don't see it in any FAQ and I cant find anything about it when I Google it.

Thanks in advance.


texts: What algorithm is used to select a voxel (from a player's perspective)?

texts:
In first-person voxel games (like Minecraft, shown below) you can select voxels by going over them. What kind of algorithm is used to select a voxel?

I haven't implemented it in my voxel application yet, but the only solution I could think of would be casting a ray and checking for intersections but it seems very inefficient.


texts: How do I get the mouse coordinates relative to my whole scene with Monogame?

texts:
I am making a topdown isometric real time game using Monogame.

I know how to get the mouse position for my camera view. How do I get the mouse coordinates relative to the entire scene?

My game's rendering looks isometric, but it's actually simply 2D and the illusion of isometric projection is done with a simple script that converts the cartesian coordinates for the mouse position to isometric ones, which I pass into a simple grid pathfinding algorithm that makes paths from them. This worked well for me when I used Game Maker.


texts: Smooth movement in point-to-move 2d game based on velocity

texts:
I have a real-time point-to-move 2D game with one playable character to control.
I want to create smooth player movement using physics and appropriate velocity.
Basic setup:

The player has a maximum speed
The player has appropriate acceleration and deceleration parameters

How I achieving the required behavior right now:
// float currentVelocity = 0
// const float acceleratePerSecond = 35
// const float deceleratePerSecond = 35

// ...

Vector2 positionToMoveTo = pointToMove.position;
Vector2 playerPosition = playerRigidbody.position;
Vector2 point = positionToMoveTo - playerPosition;

if (point.magnitude > 1) // If player is far enough
{
    if (point.magnitude >= currentVelocity) // Hack for smooth slow down
    {
        currentVelocity += acceleratePerSecond * Time.fixedDeltaTime; // Accelerate a little
    }
    else
    {
        currentVelocity -= deceleratePerSecond * Time.fixedDeltaTime; // Decelerate a little
    }
}
else // If player is close enough - stop movement
{
    currentVelocity = 0;
    pointToMove.isActive = false;
}

currentVelocity = Mathf.Clamp(currentVelocity, 0, playerService.MaxSpeed); // Clamping to fix max speed
playerRigidbody.velocity = currentVelocity * point.normalized;

This code is working but it is really hacked on the second if statement. Closer to end point player starts shaking, when the current velocity increasing in the first frame and decreasing in the next frame many times.
So the question is: How can I achieve the required smooth point-to-move movement using velocity vector?
Why I need to use velocity and can't use plain MovePosition of Rigidbody2D?
That's because I rotate a player based on that velocity. It is bad to rotate a player based on pointToMove position because the real front of the player is the current velocity vector.
Some test briefs:

If object is far enough:

   acceleration        max speed        deceleration
|-----------------o-----------------o-----------------|
                 _____________________
        ________/                     \________
 ______/                                       \_______
/                                                      \

If object is closer:

    acceleration      deceleration
|-----------------o-----------------|
               ______
        ______/      \_______
 ______/                     \______
/                                   \

Appreciate any help. Thank you.


texts: How do RPGs balance linear damage formulas?

texts:
I'm developing a damage formula for an RPG. I've checked many popular titles formulas for reference (Final Fantasy, Chrono Trigger, Golden Sun and Castlevania) and most seem to use linear functions.

My issue is that for linear functions, the % in which damage increases when leveling up goes down in every level. For example, when you go from Lvl 2 to Lvl 3 and damage increments 50%, however when you go from Lvl 50 to Lvl 51, an attack only does 0.5% more damage to the same enemy.

This coupled with the fact that XP to level up goes up exponentially in these titles doesn't make sense to me. So while I'm tempted to forgo this type of function for my game, I feel there's something I must be missing since many of my favorite games use them. Moreover I have played these titles and I never noticed this.

Eg:
Golden Sun damage calculation is a simple: Damage = Attack - Defense. Pokemon's damage formula below is a bit more complex but absolute damage growth also decreases on each level.

Am I right to think in these games damage increases at a lower percentage on each level?

How do they balance the game so that levels are still important later on the game?


texts:
I was developing an fbx converter for legend of grimrock object model (www.grimrock.net), I just wanted to get the animations cause the rest has been converted by others' tools.
I was reading all of their guidelines to convert from their little endian binary file to the format I want (in this case fbx)
When I was about to construct the skeleton, I was stuck because of this

// A Mat4x3 is a transformation matrix split into 3x3 rotation and 3D rotation parts
struct Mat4x3
{
    Vec3    baseX;
    Vec3    baseY;
    Vec3    baseZ;
    Vec3    translation;
}

(btw Vec3 is a three dimensional vector (xyz) you can find complete specifications of their object model here)

what does "A Mat4x3 is a transformation matrix split into 3x3 rotation and 3D rotation parts" mean????
Regarding the creation of bones, I thoughtmatrix should be a transformation matrix not a rotation matrix.
So I'm kinda confused.
Anyway I should calculate this way? (o = origin)

x' = x*x1 + y*y1 + z*z1 + o1;
y' = x*x2 + y*y2 + z*z2 + o2;
z' = x*x3 + y*y3 + z*z3 + o3;


texts:
I'm trying to get the physics of a retractable object in unity,
So I will be able to "launch" an elastic cable (similar to rope physics) out of an object (e.g. A gun),
And the cable will gradually/exponentially "roll back" into the object.
A good reference would be Batman's grapple gun.
I thought of utilizing it using a spring joint, but I can't really get the exact mechanics I'm trying to achieve.
Any ideas?
Thank you in advance.


texts:
Evening.

I created a xna-game like the iOS Platformer game "Banana Kong".
The level-layers are currently saved as XML files.

Example:

<level>
    <layer1>
        <tile type="0" x="50" y="70"></tile>
        .. And so on
    </layer1>
    .. And so on
</level>

Its a temporary solution, yes, but when I sell/release it, static levels are not very good.

So How I could create levels randomly?

The engine would have to pay attantion, to not create tiles, the player can't reach, or create tiles an other tiles.

My current concept is, that the engine could create random tiles as long a tile fits every condition - but there is a unlikely chance that this will never happen and I think there are better methods to do this.

So, I hope anybody could give me some resources, theories or anything, what can help me.


texts:
Backstory:
I've been developing a game with LibGDX for the past two years, and I've seen it refactored more times than I remember.

I jumped on the iOS iKVM port as soon as it was released.
But I've been struggling with it ever since in regards to cross platform networking.
Kryonet will not port over to iOS unfortunately. So it's either I ditch Kryonet, or lose a large chunk of my target audience (iOS Users)

My question for you is:
I noticed LibGDX has cross platform classes ready for sockets and HTTP Requests, but no documentation exists for these sockets at all.

Has anyone used these sockets at all in the past, and does anyone know how they work?


texts:
I'm trying to convert the following code to Java:

glVertexPointer( 3, GL_FLOAT, 0, &(mesh.m_PositionBuffer[0]) );

Where mesh::mPositionBuffer is std::vector<glm::vec3>;

How would I make a similar call to glVertexPointer with a first index to the position buffer?


texts: Best strategy (tried and tested) for using Box2D in a real-time multiplayer game?

texts:
I am currently tackling real-time multiplayer physics updates for a game engine I am writing. My question is how best to use Box2D for networked physics. If I run the simulation on the server, should I send position, velocity etc to every client on every tick? Should I send it every few ticks? Maybe there is another way that I am missing?

How has this problem been solved using Box2D before? Anyone with some ideas would be greatly appreciated!


texts: Javascript, how to make player collide with tile map


texts: How do I position a 2D camera in OpenGL?

texts:
I can't understand how the camera is working.
It's a 2D game, so I'm displaying a game map from (0, 0, 0) to (mapSizeX, 0, mapSizeY).

I'm initializing the camera as follow :

Camera::Camera(void)
  : position_(0.0f, 0.0f, 0.0f), rotation_(0.0f, 0.0f, -1.0f)
{}

void            Camera::initialize(void)
{
  glMatrixMode(GL_PROJECTION);
  glLoadIdentity();
  glTranslatef(position_.x, position_.y, position_.z);
  gluPerspective(70.0f, 800.0f/600.0f, 1.0f, 10000.0f);
  gluLookAt(0.0f, 6000.0f, 0.0f,
            0.0f, 0.0f, -1.0f,
            0.0f, 1.0f, 0.0f);
  glMatrixMode(GL_MODELVIEW);
  glLoadIdentity();
  glEnable(GL_DEPTH_TEST);
  glDepthFunc(GL_LEQUAL);
}

So the camera is looking down. I currently see the up right border of the map in the center of my window and the map expand to the down left border of my window. I would like to center the map.

The logical thing to do should be to move the camera to eyeX = mapSizeX / 2 and the same for z. My map has 10 x 10 cases with CASE = 400, so I should have :

gluLookAt((10 / 2) * CASE /* = 2000 */, 6000.0f, (10 / 2) * CASE /* = 2000 */,
            0.0f, 0.0f, -1.0f,
            0.0f, 1.0f, 0.0f);

But that doesn't move the camera, but seems to rotate it.

Am I doing something wrong?

EDIT :

I tried that:

gluLookAt(2000.0f, 6000.0f, 0.0f,
            2000.0f, 0.0f, -1.0f,
            0.0f, 1.0f, 0.0f);

Which correctly moves the map in the middle of the window in width. But I can't move if correctly in height. It always returns the axis Z. When I go up, It goes down and the same for right and left.

I don't see the map anymore when I do :

gluLookAt(2000.0f, 6000.0f, 2000.0f,
                2000.0f, 0.0f, 2000.0f,
                0.0f, 1.0f, 0.0f);


texts: move toward object and transition to circling around it.

texts:
While it's easy for me to get a object circle around another and move toward it, i've got a few problems I couldn't find a solution to, yet.

Ill go here as follows:
I) description of scenario
II) problems I currently have

I) Description:
My setup consists of multiple things:

1) I have a solar system - basically some planets rotating around the sun in a fixed circular motion with the sun itself unmoving.
This one works fine - I currently do it with rotateAround in Unity, but I read into force related methods and I think I'm able to get it designed with forces if needed.

2) Space ships. These ships are either circling around a planet (kind of "i'm stationed here") or moving toward another planet (to station them somewhere else)
The movement towards a planet as well as the circling around the planet for itself is easy as far as im concerned.. just some move-toward-point stuff or rotateAround point again. I could those 2 implemented with forces too.

II) the problems I have.

1) I can't get my head around a smooth transition from flying toward a planet into the rotation. My first idea was to use some kind of states for the ships "CIRCLING" and "FLYING" and change the state as soon as the desired orbit height is reached. (btw: I use a 3d environment but for the gamelogic I only require the motion to happen on 2d x-z axis only, if this is important to you). The problem with this is, that it's kind of a 90° turn and really looks bad.

2) the next thing i had was to just add another "Transition" state, when I get close enough, which will handle the smooth movement into the circular motion, but I don't know how to do it.

3) Do I have to care for anything else because the target I want to rotate around is moving itself? (so it doesn't look like they speed up when moving around the planet in same direction of the planets movement, while seeming extra slow when moving against planets movement)? (I ask this, because currently I only work with static planets to get the ships movement correct)

So basically my question is:
How can I implement this transition? (I don't care if it is a statebased approach with directly applied position changes (with relation to time for constant speed) or if I have to use rigidbodies and forces or if you come up with something else.)

and as an addition: I also need the ships to avoid planets when travelling somewhere - so I was thinking about using the steering behaviour for collision avoidance, which in my understanding would work well with a force based approach, but I didn't completely wrap my head around that yet.
(I don't want an answer to this part here, but wanted to provide you with a more complete specification of problems, which has to be possible to mix into the approach without hacking something together badly ;)).

thanks for any help, advice, links to useful resources :)
kind regards


texts: How can I make a peer-to-peer multiplayer game?

texts:
How can I make a p2p multiplayer game?
I would like to have a server-less multiplayer game. But then, how all the clients know each other?

Why the p2p-protocol is so famous in file transfer but not in multiplayer games?


texts: In UDK, how and where do I script to enable Alt-F4 for exiting game?

texts:
By default, Alt-F4 does not work in a UDK game.
How would I go about adding unreal script to cause the game to exit to desktop upon Alt-F4?
Update
This is what I've tried:
; Primary default bindings
.Bindings=(Name="F4",Command="exit",Alt=True)
.Bindings=(Name="F10",Command="ToggleInventory")
.Bindings=(Name="SpaceBar",Command="GBA_Jump")


texts: Is "Check your surroundings" warning on splash screen really needed for geolocation games?

texts:
I'm currently building an Android game as a solo dev. It follows the trend of geolocation-based games (like Niantic), but with more unique aspects.

Anyway, I noticed that in Niantic games - Ingress, Pokemon Go - there's always a "check your surroundings" or "don't drive and play" kind of warning to the player in the splash screen. I'm afraid that it might have something to do with legal implications regarding people being trampled or fall to their death while playing.

While I'm definitely not a fan of losing my player base / cause pain and sorrow to their families, I still see no reason to add this to my game. Because let's face it, people promptly ignore warnings like that and play the way the want in the end.

My case is somehow different from most geolocation games, in the sense that one of its unique features is that you don't need to keep looking at the screen to play. In case it helps to clarify how it works here is the play store's link: https://play.google.com/store/apps/details?id=com.arvere.theforage (I'm not sure if this is compliant with SE's rules, if it isn't, I ask to some mod to remove it, please)

So, would there be any reason (besides legal security) to do this in a game like mine?


texts:
I'm using DirectX 11 and shader model 5.

There are many tutorials online for writing engines and shaders for shadow mapping. I have found an issue which seems to have a hard to find answer.

Typical shadow maps can be created by setting null render targets, assigning a depth/stencil, and setting a null pixel shader. What about the case where I want to sample a texture to determine an objects transparency and discard the pixel based on that transparency (i.e. shadow mapping a tree or chainlink fence)? In this case I need a pixel shader which samples a texture and outputs an alpha value to determine whether to write a pixel to the depth stencil. How do I output an alpha value if there are no render targets?

The regular pixel shader for an object might be:

struct OutputStruct
{
float4 Diffuse : SV_Target0;
float4 WorldPos : SV_Target1;
float4 Normal : SV_Target2;
}
OutputStruct PS(InputStruct Input)
{
    OutputStruct output = (OutputStruct)0;
    // perform pixel shading operations
    return output;
}

This seems to be what I want:

struct OutputStruct
{
}
OutputStruct PS(InputStruct Input)
{
    OutputStruct output = (OutputStruct)0;
    // perform pixel shading operations
    return output;
}

Where do I determine whether to write to the depth stencil based on the pixel shader operations? How do I output an alpha (0 or 1 in value)?  Remember that the blend state is defined for each render target slot of which I have none.


texts: Avoid players getting stuck by placing items in the same place

texts:
Let's assume a multiplayer game of two players. These two players have to place six elements at six different positions. The order or exact place does not matter. As the items are placed correctly, they cannot be replaced anymore.

Issue: Both place an item at the same position and now there are basically two items at a position where only one should be. This makes the task impossible to complete, as one item is missing now for the last position.

My assumption is that while both are really doing that in parallel, the communication between both computers is too slow so the other player can't know there is already an item.

I encountered this issue in a game recently and I wonder how to avoid this.

The simplest solution would be that the items can be replaced when placed. But let's see it more technical: A correctly placed item cannot be replaced - so how to circumvent or how to avoid this situation?


texts: Creating movement path displays in a top-down 2d RTS

texts:
My game is a top-down 2d RTS coded in C# using SFML's libraries. I want that during unit selection, a unit will display it's movement path on the map. Currently, after the path is computed as a list of directions ({left, up,down, down, down, left}, as an example), it's sent to the graphical component to create it's UI equivalent, and here I'm having some problems. current, these I've checked three ways to do it:

compute the size of the image (in the example above it'll be a 3*2 rectangle) and create an invisible rectangle, and then go over the directions list and mark each spot with a visible point, so as to get a continous line. This system is slightly problematic because of the amount of large images that I need to save, but mostly because I have a lot of fine detail onscreen, and a continous line obstructs the view.
again, compute the size of the image, but now create several (let's say 4) invisible images of that size, and then instead of a single continous line I'll switch between the four images, in each will appear only a fourth of the spots, in a way which creates a path animation. This is nicer on the eye, but here the memory demands, and the amount of time needed to compute each such image-loop is significant.
Just create a list of single markers, each on a different spot on the path. This is very quick & easy on memory, but too sparse.

Is there a simple or resource-light system to create path-animations?


texts: Find the co-ordinates of collided objects in Python

texts:
I have a group containing my aliens and another containing the bullets I have fired. When I detect their collisions, I want to pull the alien's x-y co-ordinates during it's deletion so I can put an explosion animation in that location. How do I achieve this? My attempts so far give an error saying group items cannot be indexed.

This is my first real coding project - so still new. I'm using Pygame to make the game.

Current collision detection code:

def check_bullet_alien_collisions(ai_settings,screen,stats,sb,ship,aliens,bullets,bombs):
"""Respond to bullet-alien collisions"""

collisions = pygame.sprite.groupcollide(bullets,aliens,True,True)

#Collect X-Y co-ordinates here

if collisions:
    for aliens in collisions.values():
        stats.score += ai_settings.alien_points * len(aliens)
        sb.prep_score()
        stats.aliens_hit += 1
        stats.calc_accuracy()
        sb.accuracy()
    check_high_score(stats,sb)


texts: GLSL Editor and Debugger for MacOSX with ES2 support

texts:
is there a GLSL editor for the mac? I need it for iOS OpenGLES2 shader.

How do you best debug shader?

Regards


texts: Generate random number in Unity without class ambiguity

texts: I have a problem in Unity (C#) where I would like to create a random number. I wanted to use System.Random (reference: using System) but Unity complains that it's ambiguous to their own UnityEngine.Random. I can not specify the reference (using System.Random) as random is not a namespace. How do I specify that I want to use the system random and not the Unity one?


texts: Android black screen with Unity app in subview

texts:
I've exported an Unity app/game I have made to Android Studio. In Android Studio I made a layout and within it I have a framelayout. However, when I run the app the framelayout is completely black, why?

Here is my Java code:

public class UnityPlayerActivity extends Activity {
    protected UnityPlayer mUnityPlayer; // don't change the name of this variable; referenced from native code

    FrameLayout fl_forUnity;

    Button bt_groen, bt_gul, bt_sort;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        requestWindowFeature(Window.FEATURE_NO_TITLE);
        super.onCreate(savedInstanceState);

        getWindow().setFormat(PixelFormat.RGBX_8888);

        mUnityPlayer = new UnityPlayer(this);
        if (mUnityPlayer.getSettings().getBoolean("hide_status_bar", true)) {
            setTheme(android.R.style.Theme_NoTitleBar_Fullscreen);
            getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
                    WindowManager.LayoutParams.FLAG_FULLSCREEN);
        }

        setContentView(R.layout.main);

        this.fl_forUnity = (FrameLayout) findViewById(R.id.fl_forUnity);

        this.fl_forUnity.addView(mUnityPlayer.getView(),
                FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.MATCH_PARENT);

        this.bt_groen = (Button) findViewById(R.id.bt_groen);
        this.bt_gul = (Button) findViewById(R.id.bt_gul);
        this.bt_sort = (Button) findViewById(R.id.bt_sort);

        this.bt_groen.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                UnityPlayer.UnitySendMessage("Main Camera", "ReceiveRotDir", "G");
            }
        });

        this.bt_gul.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                UnityPlayer.UnitySendMessage("Main Camera", "ReceiveRotDir", "Y");
            }
        });

        this.bt_sort.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                UnityPlayer.UnitySendMessage("Main Camera", "ReceiveRotDir", "B");
            }
        });

        mUnityPlayer.requestFocus();
    }
}

Here is my XML:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
                android:layout_width="match_parent" android:layout_height="match_parent"
                android:rowCount="3"
                android:columnCount="10">

    <FrameLayout
        android:layout_width="match_parent"
        android:layout_height="400dip"
        android:id="@+id/fl_forUnity"
        android:background="#00FFFF"
        android:layout_centerHorizontal="true">

    </FrameLayout>

    <Button
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Grøn"
        android:id="@+id/bt_groen"
        android:layout_column="4"
        android:layout_row="2"
        android:layout_alignTop="@+id/bt_sort"
        android:layout_toRightOf="@+id/bt_sort"
        android:layout_toEndOf="@+id/bt_sort"
        android:layout_marginLeft="30dp" />

    <Button
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Gul"
        android:id="@+id/bt_gul"
        android:layout_column="9"
        android:layout_row="2"
        android:layout_alignTop="@+id/bt_sort"
        android:layout_toLeftOf="@+id/bt_sort"
        android:layout_toStartOf="@+id/bt_sort"
        android:layout_marginRight="30dp" />

    <Button
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Sort"
        android:id="@+id/bt_sort"
        android:layout_below="@+id/fl_forUnity"
        android:layout_centerHorizontal="true"
        android:layout_margin="10dip" />

</RelativeLayout>


texts:
I'm a novice that is starting to play with OpenGL ES on Android devices. To practice OpenGL I wanted to create a small game engine and so I was wondering what the best 3D model file format would be.

I'm also interested in free models of the same format.

What do you suggest?


texts: Does it make sense to use voxel editors only for meshing?

texts:
I am a hobbyist game developer. If there is something that I really don't like is 3D modeling, in particular all the work that needs to be put in the "pipeline" for the creation of models, in particular UV mapping.

Remembering games like Minecraft or "Little big planet", I was wondering if voxel editors could be used for just modeling; let me explain: using a voxel editor to make each object I need for my games and then export them singularly as FBX with either marching cubes or even better dual contouring for meshing.

Does an approach like this make sense in terms of performance? From what I can tell, I would need a voxel software which allows all of the following criteria.

Dual contouring meshing
FBX or OBJ export of meshed area
Multiple materials

Now, it looks like such software doesn't exist, which makes me think that this approach for 3D modeling may be totally wrong. Any heads-up on this?


texts: How to edit specific mipmap images in a DDS?

texts: I am looking for a way to edit individual mipmaps within a DDS file. To my knowledge, the NVidia Plugin only lets you create the largest image and then computes the smaller ones automatically. However, the problem is that after long tests with the different available algorithms and sharpening strengths I still think that at least the 2nd and 3rd of the smaller mips could look better if created manually. Is there a way to do so?


texts:
The option in the rendering menu of Maya doesn't say "Mental Ray" anymore.
Please help me to get it back, or even a better plugin for Maya game quality rendering.


texts: Combining multiple diffuse textures into one leaves strange distortions?

texts:
I made 3 models, each has own material. And after texture painting, I combined each their texture to single textures for optimization.

Currently making Mobile Game with Unity 2018 and using Mobile/BumpedSpecular shader for rendering, which is actually simplified BlinnPhong lighting model.

However after checking the result, I get weird result in some spots with Diffuse texture.

Note that Mobile/BumpedSpecular shader in Unity uses alpha channel of diffuse texture as glossiness. So after I combined those three different diffuse textures, I exported with no background(transparent background) like this:

UV mapped correctly, diffuse texture has alpha, importing alpha channel as well.

Everything seems fine, but why do I have this wrong result? First time I thought that I did something mistake, so I repeated whole process again, but still have same result, not this one, with other models also. So I thought that it was bug from Unity, actually but it wasn't, I tried with Blender and have same result.

So one thing I can know that there might be something missed in my integrated diffuse/glossiness texture. What am I missing?


texts: How to mitigate speed effects on moving platforms?

texts:
I am implementing horizontal moving platforms in my 2D platformer.

The way it's implemented currently, when my player lands on a moving platform, he is reparented to it so that his position updates in line with the moving platform.

The player is moved perfectly in sync with the platform, which has a constant velocity. The player's acceleration and velocity are not altered in any way to achieve this movement. It's free because the player is now a child of the platform.

Because I use local position in all of my player's movement code, my player is still free to move left and right relative to the moving platform.

This works really well.

I notice, however, that when my player runs along the platform in the same direction as it's moving, there is a sense of moving fast. When he runs against the platform, there is a sense of sluggishness.

I know that relative to the platform my player is moving at the same velocity in both directions, but because he traverses more global distance than normal when moving with the platform, there is a sense of speed, and because he traverses less global distance than normal when moving against the platform, there is a sense of sluggishness.

I believe the sense of speed and sluggishness are like psychological illusions. If my player stands on my moving platforms, it takes the same amount of time for him to traverse them from left to right as right to left, so I know that local velocity with respect to the platforms is working. It's more of just a psychological effect I'm trying to mitigate, I think.

So my question is: Are there any ways of mitigating these effects? How do you deal with this problem?

I am working in Godot, but would prefer an engine-neutral explanation of ways to avoid this effect.

It may or may not be relevant, but I have a smoothly scrolling camera which lerps to my player's position, as well as parallax backgrounds.


texts: Change axis to view world from above in Unity

texts:
Developing a 2d game where you view the "table" from above (think of a card game being played on a table).  I have a candlestick on the table, but I must have something wrong because when I run it, it thinks it's on a wall versus a table because the flame goes up to the top versus "at" the camera from above.

Here's the code of that "LookAt" script:

public class CameraFacing : MonoBehaviour
{
public Camera cameraToLookAt;
void Awake() {
    cameraToLookAt = Camera.main; }
void Update()
{
    Vector3 v = cameraToLookAt.transform.position - transform.position;
    v.x = v.z = 0.0f;
    transform.LookAt(cameraToLookAt.transform.position - v);
}
}


texts: How would you go about placing objects between chunks in a 2D game?

texts:
I have a 2D infinitely generated world which is split up into 9 chunks at a time. Three chunks are loaded and three are unloaded whenever a player moves into a new chunk (if the player moves up a chunk the top three chunks are loaded and the bottom three are unloaded so there's always 8 chunks surrounding the player, pretty standard). My chunks are stored as 16x16 2D arrays so I loop through the array of chunks and then through each dimension of the array to access tiles.

In my game the player can place buildings and other various things which are technically groups of tiles that take up a few spaces on the grid. The issue I'm having is knowing how to refer to adjacent chunks as to whether or not the object should be allowed to be placed.

If the player is trying to place an object within the boundaries of a single chunk this is fine and works great because I can check the tiles within that chunk easily. However when checking across chunk boundaries (worst case 4 different chunk arrays) things because incredibly complicated and bug prone.

How I'm managing it right now:

The player is trying to place a 4x4 tiled building on the boundary of ChunkArray[1,1] (always the chunk under the player, as ChunkArray[2,2] makes up 9 chunks) and ChunkArray[2,1] (the chunk directly to the right of the player.

If the 4x4 building overlaps directly down the center of the boundary, lets say ChunkArray[1,1][15,5] and ChunkArray[1,1][15,6] (two adjacent tiles, one above the other on the right side of main chunk) and therefore ChunkArray[2,1][0,5] and ChunkArray[2,1][0,6] (same thing but on left side of adjacent chunk) then I'm checking to see if those tiles in the chunk to the right are clear and the tiles in the chunk under the player are clear.

You can see how this would become hellish when dealing with objects which are even larger than 4x4 or even worse if they overlap 4 different chunks at the same time.

I also thought about treating all 9 chunks relative the player as a super-chunk and combining all the chunks into one large array which would make placing objects much easier, although I haven't really processed how realistic this would be as loading/unloading and rearranging the super chunk every time a player moved between chunks could be insane.

Is there some obvious solution I'm missing?


texts:
I know there are a lot of UDP examples out there, but I really need to know specifically what I am doing wrong. I have Wireshark monitoring my data traffic and according to that program Unity is not sending data at all. Could some of you coding wizards look over this and help me find my mistake?

public class heatLampControl : MonoBehaviour { //Ben Stewart, june 6th, 2016
                                           //this code controls the                      "Position" of the heat lamps, ie what angle the heat should be coming from. The
// value will be added to a new UDP connection to the dSPACE machine

//Update 6-10: Added UDP functionality, as accessing the UDP class that was created for this purpose turned out to not function correctly
public float lampIntensity = 0.0f; //Multiplier for relative intensity of the sunlight
GameObject sun;
public GameObject player; // dropped in via GUI
public bool isNight = false; // is it night? if so, heat lamp should turn off
public double sunAngle; // angle about the y axis. that is the only angle that can be controlled.
public bool isOn = false;
public string keyDown;
public int port;
public string dataStr;
byte[] data;
public GameObject cycle; //following three keep track of day/night cycle
public Day_Night.TimeOfDay tod;
public Day_Night dayNight;
public int strLength;
private IPAddress ip;
private UdpClient udp;
private IPEndPoint ipep;
public float fruitIntensity;
public float hayIntensity;
OlfactoryControl olfactory;
string hostname;
IPAddress[] ipList;
void Start () {
    hostname = Dns.GetHostName ();
    ipList = Dns.GetHostEntry (hostname).AddressList;
    port = 13722;
    cycle = GameObject.Find ("DayNight");
    dayNight = cycle.GetComponent<Day_Night> ();
    sun = this.gameObject;
    olfactory = GameObject.Find ("Olfactory").GetComponent<OlfactoryControl>();
    ip = ipList [0];
    ipep = new IPEndPoint (ip, port);
    udp = new UdpClient (13722);
}

// Update is called once per frame
void Update () {
    sunAngle = player.transform.eulerAngles [1] - Math.Atan2 (sun.transform.position [2], sun.transform.position [0]);// gets the positional angle of the sun compared to the player
    keyDown = Input.inputString;
    if (isNight || Input.GetKeyUp (KeyCode.L)) { // IF L is pressed down, light will come on
        lampIntensity = 0f;
        isOn = false;
    }
    if (!isNight && Input.GetKeyDown (KeyCode.L)) {
        lampIntensity = 1f;
        isOn = true;
    }
    tod = dayNight.tod;
//      if (tod == Day_Night.TimeOfDay.Idle)
//                      lampIntensity = 1.0f;
//      if (tod == Day_Night.TimeOfDay.SunRise) {
//          lampIntensity = (dayNight.timeOfDay / (dayNight.sunSet - dayNight.StartTime));
//      }
        hayIntensity = olfactory.hayIntensity;
    fruitIntensity = olfactory.fruitIntensity;

    sendUdp ();

}

//june 30th edit
void sendUdp(){

    dataStr = hayIntensity.ToString () + fruitIntensity.ToString () + lampIntensity.ToString ();
    byte[] sendBytes = System.Text.Encoding.ASCII.GetBytes (dataStr);
    Debug.Log (dataStr);
    udp.Send (sendBytes, sendBytes.Length, ipep);
    Debug.Log ("Data sent to IP Address " + ip.ToString() +  " on port " + port.ToString());
}
}


texts: Player customization of entity and handling textures

texts:
I'm developing a racing game where you can customize your vehicle with pre-made textures and also user generated ones (players can add assets to the game).

I want to know what you think is the best approach to this type of customization.

Use pre-packed textures and load the corresponding atlases for every single part (I think this is the easiest, but wastes memory having 3 or 4 atlas in memory and just using one texture of each).
Check what the user selected and pack those textures into an atlas at runtime and use that until the user changes any part and pack it again, and so on... (more complex, less gargabe in memory).

Take into account that customizable parts include: wheels, spoilers, hoods, decals, exhausts and the user also has the possibility to add content.

I've never implemented something like this so any help would be appreciated.


texts: Unity3d OverlapSphere and raycasting problem

texts:
I have a grenade (rigidbody) which make a spherecast when it detonates. On each found colliders, i will make a raycast to check if it is visible to the grenade or not.

void Explode() {

    Collider[] colliders = Physics.OverlapSphere(transform.position, radius);

    foreach(Collider coll in colliders) {

        // when the collider belongs to a player..
        if(coll.transform.GetComponent<Player_Controller>() != null) {

            RaycastHit hit;

            // ..i want to check whether its behind an obstacle or not
            if(Physics.Raycast(transform.position, (coll.transform.position - transform.position), out hit)) {

                coll.transform.GetComponent<Player_Controller>().TakeDamage();

            }

        }

    }

    Destroy(gameObject);

}

My problem is i will get the collider for all players, but when i do the raycast from the grenade to the found collider, i only hit the environment i play in. So basically my map. The grenade is laying on the ground so maybe there is an error in my raycast direction.

Edit: I solved this, the raycast was pointing not at the very bottom of the collider instead a little bit below so it was under the ground. I havent seen it unless i draw a debug ray..


texts: How can make an object orbit a sphere in a random direction?

texts:
How can I move an object on a random orbital path around a sphere?

I've created some objects at an initial position that is essentially a random point on the sphere offset by some distance (say, 10.0).

Now I want to choose a random direction and have the object orbit the sphere in that direction. How can I accomplish that?


texts: check if there are planets in the vicinity

texts:
I'm trying to make a random galaxy map in gamemaker, with several planets at random places. The problem I have run into is that some planets will be too close together. I need a way to put a minimum distance between them, but I can't figure out how to do it, or where I'm going wrong in the code.

I use the following script to make the map (argument0=amount of planets of this type to create and argument1=the object under which this type is located):

var i;
var MinDistance
var ToCloseFlag
var planetx, planety

for (i=0;i!=argument0;i+=1)
{
do
{
    do
    {
        do{
        planetx=random(room_width);
        }
        until(planetx<room_width-64 && planetx>64);
        do {
        planety=random(room_height);
        }
        until(planety<room_height-64 && planety>64);
    }
    until(place_empty(planetx,planety))
    MinDistance=400;
    ToCloseFlag = 0;

    with(argument1){
        if (point_distance(planetx,planety,other.x,other.y)<MinDistance)
            {
                ToCloseFlag=1;
            }
    }
 }
 until (ToCloseFlag=0);

    if place_empty(planetx,planety)
    {
        instance_create(planetx,planety,argument1);
    }

}

Any help would be greatly appreciated.


texts: Panning value of 2nd GameObject's AudioSource is not initializing

texts:
I'm making a prototype and stuck in a problem where two GameObjects swap but there values of panStereo of AudioSource is not initializing from a float array which contains all the default values of panStereo of all the GameObjects in a scene:
 panningArray = new float[Inventory.bowlsManager.BowlPanningValues.Length];
    for (int i = 0; i < Inventory.bowlsManager.BowlPanningValues.Length; i++)
    {
        panningArray[i]=Inventory.bowlsManager.BowlPanningValues[i];
    }
    Selectable = false;
    SelectedBowl.GetComponent<AudioSource>().spatialBlend = SelectedBowl2.GetComponent<AudioSource>().spatialBlend = 1;
    iTween.MoveTo(SelectedBowl, iTween.Hash("position", temp2, "time", transitionspeed));
    iTween.MoveTo(SelectedBowl2, iTween.Hash("position", temp, "time", transitionspeed));

    SelectedBowl.GetComponent<Renderer>().material = SubsituteMaterial;
    SelectedBowl2.GetComponent<Renderer>().material = SubsituteMaterial;
    int SelectedBowlIndex = Array.FindIndex(Inventory.allBowls.ToArray(), x => x == SelectedBowl.GetComponent<Bowl>()); ;

    int SelectedBowlIndex2 = Array.FindIndex(Inventory.allBowls.ToArray(), x => x == SelectedBowl2.GetComponent<Bowl>());
    print(Inventory.bowlsManager.BowlPanningValues[SelectedBowlIndex2]);
    print(Inventory.bowlsManager.BowlPanningValues[SelectedBowlIndex]);

   val1=  BowlPanning(SelectedBowl2 , panningArray[SelectedBowlIndex]);
     val2= BowlPanning(SelectedBowl , panningArray[SelectedBowlIndex2] );

Here is my bowl panning function:
 public float BowlPanning(GameObject BowlRequire,float value)
{
    BowlRequire.GetComponent<AudioSource>().panStereo = value;

    return BowlRequire.GetComponent<AudioSource>().panStereo;

}


texts: Trouble programming JInput for game controller

texts: Due to lack of reasonable documentation, I have not been able to program inputs for using a game controller. The most I have ever found was how to detect if a controller is found and what it's name is. Does anyone know of a reliable tutorial on how to program controller buttons to perform any actions?


texts: Is the output from D3DCompile specific to one GPU, or not?

texts:
In Direct3D 11 there is a two-stage shader compilation process; you first pass the HLSL source code into D3DCompile, which outputs a "blob" of bytecode.  You then take this blob and call CreatePixelShader or another of the CreateWhateverShader methods to finally get an object that can be bound to the D3D pipeline and used.

My question is: is the bytecode produced by the first stage machine-independent or is it specific to the GPU on which it was compiled?  I could not find a straight answer to this in the MSDN docs.  I heard somewhere that HLSL compiles to machine-independent bytecode which is then translated into GPU-specific machine code by the driver, but I have not been able to confirm this.


texts: Game Physics With RK4 Implementation For A 2D Platformer

texts:
I been reading about RK4 for physics implementation in a game, so I read in some pages and all people recommend me this page:

http://gafferongames.com/game-physics/fix-your-timestep/

This page shows clearly how this one works, but I can't figure out how to implement in my game, maybe I don't understand that good but I find some things that are not really clearly to me.

In my game, the player decides when change direction in the X-Axis but I can't figure out how with this RK4 implementation change the direction of the object, in the example the point goes side to side but I don't understand how I can control when he goes right or left.

So if anyone can give a little bit of clarity in this implementation and my problem which I do not understand I will be really grateful.

Thanks beforehand


texts: Variable Variables in unity using JavaScript?

texts:
I'm working on a custom built save system for a project a friend an myself are working on. Currently all variables that are saved to file, are stored as static variables in a global variables script file. The current save system involves running through each variable individually and saving it a line on a document, completely hard coded and very annoying to expand upon with new variables and elements in the game. I've decided to look into serialization of the global variables file, however static variables are not serializable. My solution is to use a getter and setter function, that is called instead of the direct GV.whatevervariable, that we currently use.

Ive been looking for something that allows me to store a variables name inside of another variable and then call it.

for example, say the variable in the GV script is A , the function would look like

static function getter(vget){
    return GV['vget'];
 }
 var A : string = "testcode"

where the call code would look like:

 var stuff : string = GV.Getter("A");

the problem with this though is that I keep getting "system.type does not support slicing" I currently cannot think of any other way to do this, and would really prefer not to hard code a getter and setter for each variable.


texts: Fast software color interpolating triangle rasterization technique

texts:
I'm implementing a software renderer with this rasterization method, however, I was wondering if there is a possibility to improve it, or if there exists an alternative technique that is much faster. I'm specifically interested in rendering small triangles, like the ones from this 100k poly dragon:

As you can see, the method I'm using is not perfect either, as it leaves small gaps from time to time (at least I think that's what's happening).

I don't mind using assembly optimizations. Pseudocode or actual code (C/C++ or similar) is appreciated.


texts: How to get error line when debugging APK from Logcat

texts:
I made android game by Unity and built APK. When I got error from this game, I can see the error message:

07-06 00:35:38.905: I/Unity(31609): (Filename: ./Runtime/Export/Debug.bindings.h Line: 43)
07-06 00:35:38.906: E/Unity(31609): NullReferenceException: Object reference not set to an instance of an object
07-06 00:35:38.906: E/Unity(31609):   at GameManager.OnRealTimeMessageReceived (Boolean isReliable, System.String senderId, System.Byte[] data) [0x00000] in <filename unknown>:0
07-06 00:35:38.906: E/Unity(31609):   at GooglePlayGames.Native.NativeRealtimeMultiplayerClient+OnGameThreadForwardingListener+<RealTimeMessageReceived>c__AnonStorey4.<>m__0 () [0x00000] in <filename unknown>:0
07-06 00:35:38.906: E/Unity(31609):   at GooglePlayGames.OurUtils.PlayGamesHelperObject.Update () [0x00000] in <filename unknown>:0
07-06 00:35:38.906: E/Unity(31609):
07-06 00:35:38.906: E/Unity(31609): (Filename:  Line: -1)

However file name and error line is wrong, so I can't check where exactly error came from.

I checked my logic almost 2 hours also the object references too, but there is no logic to access undefined object code.

It could be, but I can't see where it is. I must run this app because it uses Google Play Games Service, so it requires completed built APK without developlemt option checked.

Using Application.RegisterLogCallback not much help, it has exactly same result.

How do I get exact error line in this case?


texts: Can I develop XNA games without an XNACC subscription?

texts:
I'm looking forward to buying an Xbox 360 Slim 4GB to get started with XNA development. Can I develop games/apps on my Windows PC and deploy them to the Xbox without a Creators Club subscription? I'm not looking at publishing my work or putting it up on a marketplace.

And does this model of Xbox 360 support game deployment and storage? I heard that it doesn't. Can anyone confirm which model of Xbox I should purchase to begin XNA development? If I buy the 4GB Slim what development features would not be supported?

One MSDN deployment article says:

  At the very least, you will need a Silver Xbox LIVE membership, an XNA Creators Club premium membership, and a hard drive for your Xbox 360 console to be able to develop games for Xbox 360 using XNA Game Studio.

Another deployment technique article is a little ambiguous.


texts: How do I change gravity of box2d world after world is created?

texts: I want to modify the world of box2d after creating it, namely to change the gravity vector. Is there a way to do this?


texts:
I'm implementing Box2D for my 2d top down LIBGDX game and i have some struggle with two dynamic body.
Currently, my two bodies are created that way :

    BodyDef bodyDef = new BodyDef();
    bodyDef.type = BodyType.DynamicBody;
    bodyDef.position.set(this.x, this.y);
    this.body = world.createBody(bodyDef);
    PolygonShape collider = new PolygonShape();
    collider.setAsBox(16, 16);
    FixtureDef fDef = new FixtureDef();
    fDef.density = 0f;
    fDef.friction = 0f;
    fDef.restitution = 0f;
    fDef.shape = collider;
    body.createFixture(fDef);
    body.setUserData(this);
    collider.dispose();

So basicly, no rotation, no friction and no restitution. Also, my world have a gravity of 0 (since it's a 2d top down game, i don't that want them to fall). When player 1 collide with player 2, player 2 is moved backward like it was push but i don't want that. I want it to stay where he is, blocking the path to player 1 but he can also move.

Is there a way to do that ?
I have looked for some tips like catching collision with the contact listener but i don't know what to do in the preSolve method.

I'd like some help, thanks !


texts:
If you just want to get to the question and skip the background, go to the next paragraph if not, keep reading. O.k., so, I'm 13 and I make games in my spare time. They've never really been shared with anyone or anything so I decided I would enter the STEM Video Game Challenge for middle schoolers. I decided to use Stencyl to make the game and it was January so I figured I would work on it at some point. After that I joined a play at my school which takes up a ton of my time and today I realized its March 3rd which means I have 9 days to make a game-gah!

So, I have to make a game in 9 days and I'm probably going to use stencylworks. I just need an idea that I could execute in 9 days and just general tips for efficient game development. Sorry that this is kind of a loose question and thanks in advance!


texts: What caused rotation in exported blender model to jMonkey? (OGRE)

texts:
First off, I am very new to jMonkeyEngine 3 and still learning. Not exactly sure what could be causing my snowman to have already been rotated before import. I created him in blender and it was facing forward. The up axis was Z and the forward axis was Y.

For some reason when it is imported into jMonkey I got it pre-rotated which is not what I wanted nor what I coded. I just imported like this tutorial says to do in the book.

Exported as ORGE > Converted to .j3o > Imported with code.

snowMan = assetManager.loadModel("Models/Snowman/snowman.j3o");
Material matVC = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
matVC.setBoolean("VertexColor", true);
snowMan.setMaterial(matVC);
rootNode.attachChild(snowMan);

What should I look at doing to try and remedy this? Not even sure where to start. Could it be messed up in blender? The way I exported? jMonkey?

Update #1: I think it has to do with either the exporter or something I did in blender... not sure what though. Pretty sure it is not the fault of jMonkey.

Now it looks like this.


texts:
If I have class

class Game {
    public:
        Game() { level = new Level(); }

    private:
        Level *level;
        lua_State *L;
}

Where the level class has member functions such as "addObject()", how can I use that instance of the level class to bind addObject into the lua state?

The lua file may contain:

addObject("Player", 100, 100)
addObject("Enemy", 200, 100)

So to clarify, the 'Game' class contains a class 'Level' to manage things like the objects + there movement etc... Then I want to call a lua script to load the current level, which will bind the instance of 'Level' in the 'Game' class so it can call addObject() from the lua code.

I believe this is possible via LuaBind however I'm not keen on the boost dependencies, I did come across https://stackoverflow.com/questions/32416388/how-to-register-member-function-to-lua-without-lua-bind-in-c however method 1 seems to reply on 'Game' being a singleton and on method 2 I failed to bind a member method, only a normal function. If all else fails I will revert to LuaBind with it's awful dependencies.


texts: Sweep collision between two moving spheres?

texts:
Say I have a scenario like this:

Here I got two spheres (sphere A and B) that moves from on spot to another during a frame.
How can I predict where these two collide if they collide at all? In between these frames?

I tried to look it up and found this page, but I didn't understand much of it. Could someone try to explain this to me? I'm coding this in C# with XNA and I've been stuck with this issue for a very long time now


texts: Why does using .Lookat() cause the enemy to look left instead of at player, and how can I fix it?

texts:
I am new to Unity. I have searched but I couldn't find any answers on this. Here is my code:

somethingPosition = new Vector3(player.transform.position.x, transform.position.y, player.transform.position.z);
transform.LookAt(somethingPosition);

The somethingPosition only allows rotation of the Y axis so. Anyways, I have this script on the enemy AI.

The issue is this: the enemy looks at the player but looks to the left of the player. The same issue occurs when I have my follow code happen:

transform.position = Vector3.MoveTowards(transform.position, player.position, speed * Time.deltaTime);

The enemy will continue going to the left of the player but will not hit the player. What are some suggestions you guys can survive? Thanks!

I am aswell using a NavMesh and NavMeshAgent


texts: Should I use dependency injection in Unity?

texts:
As learned about dependency injection on the internet, I found that it's something that can be done simply by the Singleton Pattern.

But there are 2 completely different views on this issue:

Some people say it just adds complications to project
Others say it is a great tool to decouple classes and code

In particular there is Zenject that is made specifically for doing dependency injection in Unity.

With this in mind, should I use dependency injection in my Unity game?


texts: How can I prevent clicks from going through a GUI.Box?

texts: I have a GUI.Box that I slide in from the side of the screen. How can I prevent mouse interaction from going to any objects under it (another GUI.Button for instance, or for that matter an GameObject)?


texts: Has the Geometry Shader been abandonded?

texts:
Advice says to either limit use or not to use it at all.

Friday Facts #251 - A Fistful of Frames | Factorio:

We tried it, and it worked great. We got some speedup due CPU needing to prepare less data, but when doing research how different APIs work with geometry shaders, we found out that Metal (and therefore MoltenVK) on macOS doesn’t support geometry shaders at all. After more digging, we found an article called Why Geometry Shaders Are Slow. So we tested using the geometry shader on a range of PCs in the office, and found that while it was faster on PCs with new graphics cards, the older machines took a noticeable performance hit. Due to the lack of support on macOS and the possible slowdown on slower machines, we decided to drop the idea.

Geometry Shader Debugger · Issue #2110 · baldurk/renderdoc · GitHub:

Geometry shaders are inefficient especially when expansion is used like that and that's the case that GPU vendors explicitly recommend against.

I just wanted to let you know that geometry shaders have been virtually abandoned, since with them still being in the API not everyone is aware of that.

GPU Programming Guide - GeForce 8 and 9 Series (Chapter 4):

But in general, the potential for wasted work and performance penalties for using a GS makes it an often unused feature of Shader model 4.

OpenGL - geometry shaders

Can someone give me a list of geometry shader usages? : gamedev

Geometry shaders can be used for Level-of-Detail subdivision of geometry, and people did expect to be able to use them for that. But AFAIK it turned out that their performance in that scenario is horrible, which is why we now have tesselation shaders for that purpose.


texts: Generating Normal map from a Image with a given Albedo map

texts:
I am working on a research problem part of which involves generating normal map from a given image of a rusted object. I searched the internet for techniques to achieve the above and apparently crazybump is mentioned a lot. I tried it but it didn't produce the desirable effects. Also I am looking for a method which draws inspiration from an existing research paper not some closed source software. I turned my attention to the technique described in the this paper. Results from this technique are satisfactory for normal objects because of bias in the training data but it doesn't work very well in the case of rusted objects.
After this I focussed my attention on generating Albedo map (the above problem would become more solvable if Albedo map is obtained). Fortunately I am able to generate pretty good albedo maps for images of rusted objects. I used this paper's approach to generate Albedo maps. Now I want to know a good technique to get Normal map given an image and it's corresponding Albedo map. To give you an idea of what kind of images I am working with I am attaching a sample.

Links to research material would be really appreciated. Thanks!


texts: RTS Pathfinding without collision between units Options

texts: Ever since I made my units move to a certain location a problem has popped up that of course if I try to make two or more units go to the same place they fight for the same spot. Am I just being stupid and unity already has a way around this or do I need to do something specific? I have looked into flow field path finding but no way on how to implement it. I dont want to have to use a ready made script but some pointers and other options are more than welcome.


texts: How can I get old Minecraft style terrain biome selection?

texts:
I'm using this post as a reference for what I'm doing.

The real thing of interest is this:

As you can see, this is a Whittaker diagram, with temperature and rain considerations.

So would this be the algorithm he uses?

def rain(x,z):
    return some_fbm_perlin_noise(x,z)
def temp(x,z):
    return some_fbm_perlin_noise(x,z)
def biome_at_point(x,z):
    return diagram_at_point(rain(x,z),temp(x,z))

The issue with this is that if I assume the fbm perlin noise to be in the range [0,1] for both of them, then this algorithm only covers the bottom left half of the diagram. What is the top right half?

And also, perlin noise tends to make "short forays" into extreme ([0.9,1.0]) values, so the smaller, rarer biomes would have little tiny dots scattered around the map. An example would be the tundra: the tundra is very rare, and when it happens it probably only happens for a small area.  But what actually happens in Minecraft is that the smaller, rarer biomes are very rarely come across, but they still have a normal size.

I've tried something like this:

def rain(x,z):
    return hash(nearest_voronoi_point(x,z))
def temp(x,z):
    return hash(nearest_voronoi_point(x,z))

But this runs into the triangle problem, and a new one: the hash function, by definition, is incoherent, which means that it could put a desert next to a snowy mountain, because there are no constraints.

How does can I fill in the final triangle and not half tiny biomes everywhere, while maintaining biome coherency?


texts: How can I create a seesaw with Farseer Physics Engine?

texts:
I want to create a seesaw like in this picture:

I created two rectangular bodies, one for the diagonal rectangle and one for the little rectangle in the middle. But I don't know how to connect the two bodies. How can I do that?

How can I create a seesaw with Farseer Physics Engine 3.5?


texts: How to scale player as they travel between 2 points

texts:
I'm doing a VR Project where the player walks down a hallway.

The player starts with a size of 10 and is supposed to scale down to a size of 0.5 (well the GameObject in which all the player stuff is inside is supposed to do the scaling). The script below is on the GameObject which has all the player things like the camera, hands and so on are inside it.

I'm not very good at coding so I'm pretty much failing on managing to write this script. this is how far I have gotten:

public class ScalePlayer : MonoBehaviour
{
    public GameObject minDistance;
    public GameObject maxDistance;

    public Vector3 maxScale;
    public Vector3 minScale;

    Vector3 posStart;
    Vector3 posEnd;
    Vector3 curDistance;
    Vector3 distance;

    void Start()
    {
        posStart = minDistance.transform.position;
        posEnd = maxDistance.transform.position;

        maxScale = transform.localScale;
    }

    void Update()
    {
        distance = posStart - posEnd;

        curDistance = transform.position - posEnd;

        transform.localScale = Vector3.Lerp(maxScale, minScale, curDistance);
    }
}

In my logic I have an invisible object for the start point and one at the end to save where the player is supposed to be big and where they should be small.

I don't know though how or where to put my scaling values (10 -> 0.5) and the script itself is throwing errors (probabaly because I really am not sure how to get the current position of my player compared to the start and end of the hallway).

But what I hope for, is that when the player walks down the Hallway and gets closer to my invisble end point, they smoothly shrink down to the size of 0.5 on their way there, and when they decide to go back, they scale up gradually on the way to the start to 10 again when they reach the beginning.

Working with Unity 2019 and C#.

Halfway solved my problem but I am Stuck with VRTK4. But thank you for the Edit DMGregory.

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class ScalePlayer : MonoBehaviour
{
    public GameObject minDistance;
    public GameObject maxDistance;

    float StartScale = 10;
    float EndScale = 0.5f;

    Vector3 posStart;
    Vector3 posEnd;
    float curDistance;
    float dist;

    public Transform movingPlayer;

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

        posStart = minDistance.transform.position;
        posEnd = maxDistance.transform.position;

    }

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

        dist = posStart.x - posEnd.x;
        curDistance = movingPlayer.position.x - posEnd.x;
        float shrinkProgress = Mathf.Clamp(curDistance, 0, dist) / dist;
        float scale = EndScale + ((StartScale - EndScale) * shrinkProgress);
        transform.localScale = Vector3.one * scale;
        //movingPlayer.transform.position = preScalePos;
        //Vector3.Lerp(Vector3.one * StartScale,Vector3.one * EndScale, curDistance);
        //Vector3 preScalePos = movingPlayer.transform.position;
        //transform.position = child.transform.position;

    }
}

Was my first time posting anything anywhere, so sorry for not getting it 100% right the first time with how things are supposed to look.

If anyone has tried something like this with VRTK and has any idea how to scale the player, I would appreciate the help.


texts: What is the package-lock.json file for in Unity?

texts:
My project contains this file:
Packages/packages-lock.json
And I'm curious about what it's for. It has a bunch of json about my packages in it, but it's not clear to me what goes in the lock file vrs the normal packages file.


texts: How are real world car characteristics translated to in-game?

texts:
I am just entering the world of game development, starting with the racing genre of games.

Let me clarify that this question is not about car modelling or external detailing; it is about the way a car drives, handles, and the way it feels (how heavy or torque-y it is, or how fast and nimble it is, the way it moves in place when you hit the brakes, etc.) in-game.

I am looking to understand the process game developers take to translate real world car characteristics and physics into in-game cars. I am not talking specifically about simulation games; I'm including even arcade games where driving a muscle car feels very different from driving a tuner, or a sports car, or super and hyper cars.

Questions such as the following arise:

(1) Do developers have get their hands on a car physically in order to be able to map it into an in-game car? When they drive it around, what metrics are they looking to capture so their in-game car can feel as true to the real one?

(2) What if they can't get a physical car, or if the car is a concept with no drivability? What metrics, data and telemetry should the car manufacturer supply in order for the car to be represented in-game?

(3) Within cars of the same kind, such as muscle cars, how do developers ensure that a Ford Mustang, a Dodge Challenger, a Chevrolet Camaro, all feel sufficiently distinct from each other in-game? How do they ensure a Porsche 911 Turbo, a 911 GT3, a 911 GT2 all feel different, just as the real cars do?


texts: Using Flash IDE to link nodes for Dijkstra algorithm

texts:
I'm trying to use plash to set up the node connections, but having a really hard time to use the IDE as a tool to do so. Before giving up completely, and getting into creating a tool that would take assets and encode the information (by placing nodes and allowing one to drag links from one to another), I wanted to put this question out there and see if anyone has any idea how I can show a connection between these nodes as a line.

Drawing actual lines is not working well, because lines have to be moved as objects are updated, they are imprecise, and cannot carry weight information.

I'm experimenting with components and live views, which allows placement of nodes, but I can't get it to draw the lines.

I don't want to forgo using the connections completely, because it could make paths that go through objects unless I set up low proximity settings, which would require way too many objects.


texts:
I'm developing a voxel game, but I think I use the wrong technique.
I currently use flat tiles, to make blocks, and I think theres a better and more efficient way.

I have seen a voxel game, which have naturally looking terrain. By that I mean non blocky.
The game have 4*4*4 blocks per cubic meter, and blocks like dirt, sand and stone, have round edges, and kind of melt together (Like in ordinary games). Heres a screenshot

How is this achieved?


texts: Why is clip space always referred to as "homogeneous clip space"?

texts: I've noticed in almost everything I've read so far that the term "clip space" is prepended with the word "homogeneous". Now I understand that it roughly means "all the same", but I don't understand why there is the express need to say "homogeneous clip space". When is clip space not homogeneous and why do we need to differentiate? And for that matter, what exactly does it mean that we're calling it "homogeneous clip space"? Homogenous in relation to what? In what way are the vertices "all the same"?


texts:
I've been working on creating spheres in a 3D space recently, and have successfully created cylinders. I've just run into a little problem. For some reason, my "Spheres" end up looking like very thick star shapes. I can't seem to figure out what's wrong, and I could not really find any algorithms to reference off of. My code:

public static void createCircle(int xoff, int yoff, int zoff, int FOV, ArrayList<Point3D> Points, int radius) {
    for(int j=0;j<Math.PI*2;j++) {
        int x = (int) (radius * Math.cos(j));
        int y = (int) (radius * Math.sin(j));
        Points.add(new Point3D(x+xoff, y+yoff, zoff, FOV, 900, 600));
    }
}
public static void createSphere(int radius, int height, int FOV, ArrayList<Point3D> Points, int posx, int posy, int posz) {
    for(int z=0;z<height;z++) {
        createCircle(posx, posy, posz+z, FOV, Points, (int) (radius*(Math.sin(z)*2)));
    }
}

Here's what it ends up looking like:


texts: Finding closest object to a location within a specific perpendicular distance to direction vector

texts:
I have a location and a direction vector indicating facing, I want to find the closest object to that location that is within some tolerance distance (perpendicular distance) to the ray formed by the location and direction vector. Basically I want to get the object that is being aimed at.

I have thought about finding all objects within a box and then finding the closest object to my vector from them results, but I am sure that there is a more efficient way.

The Z axis is optional, the objects are most likely within a few meters of the search vector.


texts: What Java class should I use to represent a Vector?

texts:
Does Java have a built-in Vector class suitable for handling collision detection / response? It should have methods like subtract(Vector v), normalize(), dotProduct(Vector v), ...

It seems logical to use java.awt.Rectangle and java.awt.Polygon to calculate collisions. Would I be right to use these classes for this purpose?

I understand collision detection; I'm only wondering what approach to it is idiomatic in Java. I'm new to the language and to application development in general.


texts: Why do I get an exception when accessing my sprite members in this fashion?

texts:
I'm getting a NullReferenceException error on the line where I do new Vector2(...).

I think the problem is with the variables I'm using even though they're working to control the player sprite, so surely they can't be null, right? That is, however, in a different class and is initialized at the top of this one.

Here is the method in question:

public void Shoot()
{
    //if bullet delay resets then shoot
    if (bulletDelay >= 0)
        bulletDelay--;

    //if bullet delay is 0 then create a bullet at player bulletPosition
    if (bulletDelay <= 0)
    {
        //Here I create the new bullet passing in the texture and then modifying the bulletPosition were the bullet will appear from
        bullets newBullet = new bullets();
        bulletPosition = new Vector2(mySprite.imgX, mySprite.imgY);

        newBullet.isVisible = true;
        //These two lines mean that you can have no more that 20 bullets on screen at once
        if (bulletList.Count < 20)
        {
            bulletList.Add(newBullet);
        }
    }

    //reset bullet delay
    if (bulletDelay == 0)
        bulletDelay = 10;
}

bulletDelay is so the player can't spam the shoot button and have it be too easy. I tried to add a breakpoint on that line, when I run the program and hit the space bar that runs the Shoot() method the program stops and tells me about the error. When I hover over though it still says they are null.

I had the instances of the classes in the following code below. I've changed it so they are in the Shoot() method and all seems to well however I'm curious as to why the below code wasn't the correct way to do it:

public void Initialize()
{
    mySprite = new PlayerSprite();
    bulletList = new List<bullets>();
}


texts: SFML: How to draw/render from Screen class

texts:
Game architecture is as follows:

// main.cpp

main() loads data from .csv/.json files.
main() creates an Application class instance as app and passes it data.
main() runs app.genesis();

// Application.cpp

Application::genesis() creates an sfml window
Application::genesis() creates a Menu class : public Screen as screen

// main.cpp

main() runs app.loop()

// Application.cpp

Application::loop() calls screen.step();

// Menu.cpp

Menu::step() calls draw()/render();

How do I either call Application::draw()/render() from Menu::draw()/render()
or in which way should I pass screen (Menu) the window to draw to?


texts:
This is really ungrateful question to Google.

Basically, I would like to know, regarding openGL, what are various methods to do some kind of computation in one of the shaders and have the results stored in VRAM to be used and accessed at a later time?


texts: Understanding diffuse lighting in The Division

texts:
Here is a screenshot of the main character walking under a bright lamp:

His hat, that was originaly dark grey, turns completely white. My question is how can such lightsource do this without making everything around it superbright? Cuz that's what my humble attempts resulted in.

I can only think of two options:
 - they either use a standard diffuse formula (it has got to be diffuse light as it does not react to camera movement) and have a lightsource that fades extremely quickly (fastar than the standard quadratic attenuation model.
 - or they use some clever shaders for clothes to make them "catch light" so fast.

Maybe there is an easier solution?

Here are two more shots, the floor is not nearly as bright as the character that goes under the lamp:

UPDATE: I think I got my problem - they have a different attenuation formula. I think if I improve my attenuation I whould be able to achieve similar results.


texts: How can I set up a loading screen in Panda3D?

texts: How would I go about using Double Buffering (to create a loading screen) in Panda3D using C++? I've searched Google and found some forums that talk about the concept of swapping buffers, but I haven't seen any that show any type of source code (specifically Panda3D/C++). I'd like to try and stay away from using pure OpenGL code and work it through Panda3D, but if I have no other choice, then I'll have to go with OpenGL coding.


texts: Import Material from blender into unity Export FBX

texts:
There have been several questions like this but nothing that is quite the same.  I've noticed when Mixamo can create models with materials attached in their FBX.
I'm trying to do the same in blender, several people say that this cannot be done.

When I export an FBX from unity how can I get the material in with it, whether, that be importing the material through a separate process, or some how baking them in with the FBX?


texts:
Hello, I have a question about algorithm A * !

S : Start.

D : Destination.

W : Wall.

My hero goes from S and the destination is D, W is the walls, my hero can't go in there. If I use the algorithm A *, the hero will go from Cell (3,3) then to Cell (2,2) and finally to Cell (1,1).

It would be very logical if my hero is only a point. But my hero is about the same size of a Cell. So if my hero goes from Cell (2,2) to Cell (1,1), he will be hit by two walls. Each cell is 32 * 32 in size, my hero moves pixels by pixel, so he can collide with the edge of a cell. I have a collision test function, and thus the hero cannot move on.

Can someone help me, thank everyone !


texts:
I am using 3 classes:

EnemyBullet : MonoBehavior
EnemyBulletType1 : EnemyBullet

EnemyBullet Class:

void FixedUpdate(){
    this.gameObject.transform.rotation = Quaternion.Euler (new Vector3 (0,0,90));
}

EnemyBulletType1 Class:

override void FixedUpdate() {
    base.FixedUpdate ();
    //Do something else here
}

The reason is I'll have many EnemyBulletType classes and I want them all to do a common thing and then do something on their own.

Question:
This code isn't working: Error: virtual or abstract members cannot be private
How is FixedUpdate() defined in the MonoBehviour and how to change it to help my usecase?


texts: How to prevent 2D camera rotation if it would violate the bounds of the camera?

texts:
I'm working on a Camera class and I have a rectangle field named Bounds that determines the bounds of the camera. I have it working for zooming and moving the camera so that the camera cannot exit its bounds.

However, I'm a bit confused on how to do the same for rotation. Currently I allow rotating of the camera's Z-axis. However, if sufficiently zoomed out, upon rotating the camera, areas of the screen outside the camera's bounds can be shown.

I'd like to deny the rotation assuming it meant that the newly rotated camera would expose areas outside the camera's bounds, but I'm not quite sure how. I'm still new to Matrix and Vector math and I'm not quite sure how to model if the newly rotated camera sees outside of its bounds, undo the rotation. Here's an image showing the problem:

http://i.stack.imgur.com/NqprC.png

The red is out of bounds and as a result, the camera should never be allowed to rotate itself like this. This seems like it would be a problem with all rotated values, but this is not the case when the camera is zoomed in enough.

Here are the current member variables for the Camera class:

private Vector2 _position = Vector2.Zero;
private Vector2 _origin = Vector2.Zero;
private Rectangle? _bounds = Rectangle.Empty;

private float _rotation = 0.0f;
private float _zoom = 1.0f;

Is this possible to do? If so, could someone give me some guidance on how to accomplish this? Thanks.

EDIT: I forgot to mention I am using a transformation matrix style camera that I input in to SpriteBatch.Begin. I am using the same transformation matrix from this tutorial.


texts: Why does VertexPositionColor seem incompatible with Monogame?

texts:
This question is a continuation of What causes this InvalidOperationException when drawing primitives?.

I've been dealing with HLSL shaders in Monogame over the past few days. It has been extremely time-consuming and frustrating trying to duplicate shader functionality I was able to achieve easily with vanilla XNA. As an example, rendering a fullscreen quad using VertexPositionColor elements fails with the following error.

Up until this morning, I had been using the BasicEffect class with as many configurations as I could think of without success. After it became clear that BasicEffect couldn't achieve what I wanted, I wrote a simple custom shader that looks like this.

struct VertexShaderInput
{
    float4 Color : COLOR0;
    float4 Position : SV_POSITION0;
};

struct VertexShaderOutput
{
    float4 Color : COLOR0;
    float4 Position : SV_POSITION0;
};

VertexShaderOutput VertexShaderFunction(VertexShaderInput input)
{
    VertexShaderOutput output;
    output.Color = input.Color;
    output.Position = input.Position;

    return output;
}

float4 PixelShaderFunction(VertexShaderOutput input) : COLOR0
{
    return input.Color;
}

technique Technique0
{
    pass Pass0
    {
        VertexShader = compile vs_4_0 VertexShaderFunction();
        PixelShader = compile ps_4_0 PixelShaderFunction();
    }
}

The shader above seems reasonable because, as the name VertexPositionColor implies, I only need position and color. But using that effect in place of BasicEffect didn't change anything either. I finally started digging more deeply into vertex declarations (something I had no knowledge of until today) and came across the following source code for VertexPositionColor.

VertexElement[] elements = new VertexElement[]
{
    new VertexElement (0, VertexElementFormat.Vector3, VertexElementUsage.Position, 0),
    new VertexElement (12, VertexElementFormat.Color, VertexElementUsage.Color, 0)
};

Based on those lines, the vertex declaration is expecting 1) a Vector3 position and 2) a color. That seemed like the answer I needed, since in my shader, position is float4 rather than float3. But changing position to float3 produced the following error.

So, to recap and describe what I can see so far:

I'm trying to render a quad using four VertexPositionColor elements.
Rendering fails because the vertex shader input (defined in my shader code above) represents position using float4 rather than float3.
I can't change position to use float3 because the shader compiler version (vs_4_0) doesn't allow it (I think the shader version is relevant).

This whole this is just very confusing, especially since I've used shaders like this successfully in the past with XNA rather than Monogame. Is there a solution to this problem apart from creating my own custom VertexPositionColor replacement class with its own custom vertex declaration? That all seems overkill considering the simplicity of what I'm trying to do.

This issue echoes a general feeling I've gotten that HLSL shaders in Monogame are, for lack of better phrasing, messed up. Can anyone help clarify all this?

Thank you.


texts: Adjust Aim Angle for Motion with Accelerating Bullet

texts:
So, here's my problem:

I have a turret attached to a ship that moves at a variable speed through my game world, shooting at the centre of another ship travelling through the game world in a possibly different vector. Currently, I get the angle that I need to shoot at using atan2:

double targetAngle = Math.Atan2(ship.CurrentTarget.Position.Y - ship.Position.Y, ship.CurrentTarget.Position.X - ship.Position.X);

This works fine when both ships are stationary, or moving very slowly, but if moving faster, the aim lags behind. An additional fun part of the puzzle: the bullet's vector isn't static, they start at 0 and increase in speed. Their position is calculated as follows:

var direction = new Vector2((float)Math.Cos(currentRotation),
                (float)Math.Sin(currentRotation));

            if (direction.Length() > 0)
                direction.Normalize();

            var velocity = new Vector2(direction.X * MotionData.CurrentSpeed,
                direction.Y * MotionData.CurrentSpeed) + additiveVector;

Where additiveVector is my ship's vector at the point the projectile was launched. CurrentSpeed will be added to every frame until it hits a static maxspeed.

So far, the problems I've encountered with other solutions for compensating my aim is that the formulas rely on a static velocity for the projectile, and mine isn't.


texts:
i have this function which aligns text.

static function AlignTxt(obj : GameObject, txtAnchor : SpriteText.Anchor_Pos,
txtAlign : SpriteText.Alignment_Type)
{
obj.GetComponent(SpriteText).SetAnchor(txtAnchor);
obj.GetComponent(SpriteText).SetAlignment(txtAlign);
}

The above function is called from this function..

txtlib.AlignTxt(powerTxt, SpriteText.Anchor_Pos.Middle_Left, SpriteText.Alignment_Type.Center);

But i get this error on AlignTxt Function :

The name 'SpriteText.Anchor_Pos' does not denote a valid type ('not found').
The name 'SpriteText.Alignment_Type' does not denote a valid type ('not found').

Can you please help me to solve the error..Thanks..


texts:
In my Entity class I've got a function that returns a specific component, that looks like this:

template<typename ComponentType>
ComponentType* GetComponent() {
    for(unsigned int i = 0; i < m_Components.size(); i++) {
        if(ComponentType* cmp = dynamic_cast<ComponentType*>(m_Components[i])) {
            return cmp;
        }
    }
    return NULL;
}

I heard that dynamic_cast is not really elegant and that is also slow. Is there a way to optimaze this code and if so how? Is it really a big deal or does it not matter in a small Super Mario sized 2D platformer?


texts: Button image on game menu is updating too slow

texts:
I'm using SDL2 and i'm facing a problem with my game menu buttons.

Every time i detect that the mouse pointer is over a button of the menu i update the image of the button (from MOUSE_OUT to MOUSE_OVER).When i move several times and fast the pointer over the button and then i stop pointing at it the button image keeps updating. Like if the updating of the screen were not synchronize with the update of the events.

My guest is that because i'm polling the events by using SDL_PollEvent() there still events on the queue to poll and that causes the update of the images.

How can i avoid this problem of latency between the polling of events from the poll and the update of the image?

This is the method i use to check if the pointer is over the button. The input object keeps the type of event and the event itself.

int MenuState::update(GameEngine g)
{
    state_play = MOUSE_OUT;
    state_exit = MOUSE_OUT;

    switch(input->get_type()) {
        case MOUSE_PRESSED_EVENT:
            if((input->get_x_pos() > POS_X_PLAY_BUTTON) && (input->get_x_pos() < (POS_X_PLAY_BUTTON + 400)) &&
                (input->get_y_pos() > POS_Y_PLAY_BUTTON) && ( input->get_y_pos() < (POS_Y_PLAY_BUTTON + 100))) {
                state_play = MOUSE_CLICKED;
                next_state = Game;
            }

            if((input->get_x_pos() > POS_X_EXIT_BUTTON) && (input->get_x_pos() < (POS_X_EXIT_BUTTON + 400)) &&
                (input->get_y_pos() > POS_Y_EXIT_BUTTON) && ( input->get_y_pos() < (POS_Y_EXIT_BUTTON + 100))) {
                state_exit = MOUSE_CLICKED;
                next_state = Game_Over;
            }
            break;
        case MOUSE_MOVED_EVENT:
            if((input->get_x_pos() > POS_X_PLAY_BUTTON) && (input->get_x_pos() < (POS_X_PLAY_BUTTON + 400)) &&
                (input->get_y_pos() > POS_Y_PLAY_BUTTON) && ( input->get_y_pos() < (POS_Y_PLAY_BUTTON + 100))) {
                state_play = MOUSE_OVER;
            }
            if((input->get_x_pos() > POS_X_EXIT_BUTTON) && (input->get_x_pos() < (POS_X_EXIT_BUTTON + 400)) &&
                (input->get_y_pos() > POS_Y_EXIT_BUTTON) && ( input->get_y_pos() < (POS_Y_EXIT_BUTTON + 100))) {
                state_exit = MOUSE_OVER;
            }

            break;
        default:
            break;
    }
}

This is where i poll the events.

TypeEvent InputManager::poll_event()
{
    TypeEvent t;

     if(SDL_PollEvent(e)) {
        switch (e->type) {
            case SDL_QUIT:
                input = new QuitInput(QUIT_BUTTON);
                t = QUIT_BUTTON;
                break;
            case SDL_KEYDOWN:
                input = new KeyboardInput(KEYBOARD_EVENT);
                t = KEYBOARD_EVENT;
                break;
            case SDL_KEYUP:
                input = new NoneInput(NONE_EVENT);
                t = NONE_EVENT;
                break;
            case SDL_MOUSEMOTION:
                input = new MouseInput(MOUSE_MOVED_EVENT);
                t = MOUSE_MOVED_EVENT;
                break;
            case SDL_MOUSEBUTTONDOWN:
                input = new MouseInput(MOUSE_PRESSED_EVENT);
                t = MOUSE_PRESSED_EVENT;
                break;
            default:
                input = new NoneInput(NONE_EVENT);
                t = NONE_EVENT;
                break;
        }
        input->set_input(e);
        return t;
    }
    return NONE_EVENT;
}

This is my first try in order to make an input system and is not complete or totally optimal.

Thanks in advance!


texts:
I've been trying to learn OpenGL ES 2.0 to create a simple 2D game. I bought a book on android development, but after seeing that the author uses his own SDK that implements OpenGL ES 1.0 I decided to just use online tutorials. I've been so lost trying to find out what to use. The Matrices and shaders of 2.0 confuse me and I can't find any tutorial that just explains how to texture map a simple 2D image.
Basically:

OpenGL ES 1.x or 2.0 for simple 2D with little OpenGL experience
If 2.0 Any good tutorials for 2.0, I've found so many for 1.0


texts:
Within a game I want to schedule 'events', like a resource is running out, some storage is full, or a person is born. I see two ways of achieving this:

Check on all the parameters every fixed time interval. At that given time, the number of persons are adjusted, the resources are calculated...
Calculate the time at which something happens and use a database to store all these events. Create a 'scheduler' which sleeps until the first event happens, and do something. However, if one piece of data changes, all the other items also changes and need to be recalculated.

Is there a general approach how to solve this problem in game design? I hope my question is somewhat clear...


texts: XNA: How to capture precise time of button press?

texts:
I'm guessing the default XNA model encourages checking for button presses in Update(). However, I am developing a game-like application for research and need to measure reaction times as quickly as possible. If I only check button presses in Update(), this constrains me to the refresh rate of the application. For example, if Update() runs 60 times per second, button capture times could be off by up to 16.6ms (1/60) if they happen soon after the thread goes to sleep. Is there another way to design my application to catch button presses as soon as possible?

Should I run a separate thread that polls the game controller and runs faster than the regular application's 60 Hz, say 120 Hz?

Or should I run a thread that gets a hardware interrupt when a button is pressed and store the time?

Other ideas?

(I know this sounds excessive when we are talking about button pressing and 20ms or less, but there are a number of scientific applications out there that advertise millisecond level timing precision. I am just wondering if I might be able to get something reasonably close with XNA.)


texts: Unity - best way to make intro with images

texts: I have made and rendered an intro in blender for my unity game. The intro currently consists of 150 PNG-images. Should I make it into a video before importing it to unity or should I just import the images to unity and handle the animation there and if so how do you do that?


texts: Optimise Gear-VR text rendering with Unity

texts:
I have a problem with my text being always kind of broken, so there are just some parts of the text visible (parts of letters) and the text flickers a lot.

At the moment I have this text 2D-UI text inside a canvas. Are there some optimisation techniques to resolve this issue, or are these glasses just not made for such "fine" lines? And no, it's not extremely tiny text and this does not happen in such an extreme way, when I display the text as an imported image.

Sorry for the lack of images, but I don't know how to capture an image from the app since I can't open the Oculus menu.

Update:
I figured out, that at a particular font-size, the flickering decreases a lot. I will investigate further on that.

Update:
Actually there is a particular font size, which is fine and everything larger works fine too. So I think you have to deal with pretty large font-sizes to prevent the text from flickering.


texts: How to become a Ph.D. in video game design?

texts:
The title says it all, I am wondering if it is possible and if so, how it would be possible, to become a Ph.D. in video game design. I'm quite sure you can become a Ph.D. in pretty much anything, but since video games are such an informal and relatively young sector, I thought I'd ask.

Thanks in advance!


texts:
I just finished a game for my design class and I ran into a problem that I always have but this time I'm going to learn the right way to do it. I was making the background animation for my menu in photoshop (just moving layers and tweening them)and I ended up rendering out 300 frames as pngs. I always do animations this way because the only way I've learned how to write animation engines is to use a root file name and append 00x on the end to get the current frame or to create an array of images to then loop through. This results in me having large numbers of individual images in my assets folder. Is there a better way to do animations? Both programmatically and in making them. I want to hand draw the frames most of the time but I don't usually want vector images. (So no flash unless its changed recently.)

Thanks!
(I'm working off no sleep for three days now so if I need to clarify let me know)


texts: Is an inertia tensor in local-space always diagonal?

texts:
I'm looking at the implementation of a physics engine and I observe that the inertia tensor of a rigid body, in local-space coordinates, is stored as a 3 dimensional vector, rather than a 3x3 matrix, and the description says "A vector with the three values of the diagonal 3x3 matrix".
A diagonal matrix is one with all zero off-diagonal entries.
What I don't understand is why the inertia tensor in local coordinates would be diagonal?  Why couldn't it have non-zero off-diagonal entries?


texts: How does Actionscript choose which order to run objects' code in?

texts:
I can only assume that Flash runs code in the order that objects were created - so newer objects are run later. Is this true?

Is there any way, other than deleting and recreating objects, that I can change this order?