texts: Shifting the camera and setting a new scene when using Box2D

texts:
My jsFiddle:

// START -- MOVE CAMERA
var p = new b2Vec2();
p = (ball.body.GetWorldCenter().x) * physics.scale;
pos.push(p);
var length = pos.length;

var s = (pos[length - 1] - pos[length - 2]); //in pixels

if ((halfwidth < (dw - p)) && (p > halfwidth)) {
    ctx.translate(-s, 0);
}

I followed this tutorial, but the ball rendering is acting weird and slow.

I can't figure out how this example did it. He used 3 variables (stage,x, y) that are undefined in the code he wrote. Also check out how the camera moves with the player in this ImpactJS demo. I'd like to have that.

How can I do this?


texts: I want to drop a platform after I land on it

texts:
I want to disable z-axis translation lock 2 seconds after my player hits the object in question. I am using Unreal 4. Been slamming my head against it for a week and a half, please save this newb.

I just noticed this is the iteration where I enabled gravity instead of disabling z lock... the intended result is be the same for both of these

UPDATE

now the thing drops but it doesnt wait for the timer

UPDATE! I DID IT!


texts: How can "Box Collider is trigger" apply to the Player, not the enemies (make them collide, not pass through)?

texts:
So, in my game, the Powerup (capsule) has a RigidBody and a Box Collider.  I’ve set the Box Collider to «is trigger». When the player hits the powerup, it disappears - just as it’s supposed to.

Is it possible to let the enemies collide with the powerup (bump into it) instead of just passing through it? From the Enemy script:

    void Start()
{

        enemyRb = GetComponent<Rigidbody>();
        gameManager = GameObject.Find("GameManager").GetComponent<GameManager>();
        player = GameObject.Find("Player");

}

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

    if (player != null && gameManager.isGameActive)
    {
        enemyRb.AddForce((player.transform.position - transform.position).normalized * speed);
    }

    if (transform.position.y < -4)
    {
        Destroy(gameObject);
        gameManager.UpdateScore(pointValue);
    }
}

From the PlayerController script:

private void OnTriggerEnter(Collider other)
{
        if (other.CompareTag("Powerup"))
        {
            hasPowerup = true;
            Destroy(other.gameObject);
        }
}


texts:
Should I be using premultiplied alpha?  Reading Tom Forsyth's article it seems a nobrainer.  Premultiplied alpha (AKA additive blending) is superior in every sense.
However, premultiplied alpha seems to have one major drawback, it's not well supported with tools.

Do you/have you used premultiplied alpha?

How is the tool support?

In particular, I don't think gimp will edit premultiplied alpha images well.  Are there any gimp plugins to export premultiplied alpha?  How about an external tool?


texts: Merging custom c++ engine with Unreal Engine

texts:
I have my own custom C++ game engine with networking, game logic (most important) suitable for type of games I am working with etc.

I find it harder and harder to keep up with other engines in case of graphical part.

I wonder if it's possible to merge my C++ engine with Unreal Engine? And if so, what would be the best practice for it?

What I mean is to keep my already established game logic and data modules and use UE to render meshes ordered by game logic (I can easily detach the rendering part of my engine, because it's closed into few abstract interfaces that I can implement again with calls to another API or custom code), as well as do some simple physics (the type of games I do do not require too much of physics simulations). That way I could benefit from both UE rendering superior and my engine's tailored game logic module.

I know it's possible to extend UE with custom plug-ins, but I'm not sure it would be the best approach for me.


texts: Ideas for fair travelling system for text based RPGs

texts:
I'm working on a text RPG (in principle similar to cantr.net) that allows players to role-play their characters in a player-driven world. Players form cities, societies and so on. Pretty much nothing is predetermined for them including currency, etc.

The thing I'm struggling with is how to strike a balance between "pro" players that are logged in nearly 24/7 and more casual players that would like to log in once a day/two days. Most of the systems already take that into account and I'm fairly happy with them, but I'm struggling with creating traveling system that would be fair both ways.

Currently for crafting and other things I'm using "energy" points that are capped at X number and regenerate Y number per hour (basically it regenerates every three real-life days so allows for some catch-up if you miss a day or two). Could it be applied somehow to traveling? What are your ideas?

The world is a flat surface with x/y coordinates the "locations" are just specific points on a map that users can go to and while in the same "location" they can interact with each other. Kinda like Fallout 1 map. I was thinking of allowing movement of X units per 1 energy + some bonuses if vehicles/horse is used.

Let's assume this situation: a thief steals something in a town and starts to run. The game shouldn't require the guards (which are player characters) to be online 24/7 to be able to catch up. They need to have some form of slack or catch-up mechanic to be able to compete, but the thief shouldn't be severely punished by that either. I don't want to force guards to be online too much but at the same time I'm trying not to create a situation where guard characters can just talk freely and "don't give a shit" for a day and then go and chase because they know they will catch him easily.

What are your thoughts on this?

EDIT:
As requested I'm going to include a bit of more context here. The game itself has no goals, quests or really any "purpose". All that I need to provide is a world and mechanics that allow player characters to craft, fight and live in a sandbox world and do whatever they wish. Players are "role-playing" in the Dungeon & Dragons sense - they actually have to play and talk from the perspective of their character.

But since I can't expect players to be logged in 24/7 I need to create a fair (or close) system with respect for players' time.

The biggest problem I have is with travel. Not travel per se but chasing mostly. How not to require constant logging in and checking if something happened, allow to catch up to someone who logged in earlier/in different timezone but give the chance to escape as well.

I was thinking about energy points (so players would have to strategize and leave some "just in case") and using something like Tracking skill which would influence how well one character can find another character in travel.


texts: How to add friction to Unity HingeJoint?

texts:
I attach a rigidbody to a HingeJoint in Unity.

It's attached no at the the center of an anchor of a joint.

To stop it from falling I set Use Motor = true, Target Velocity = 0 and apply some force to the motor.

However, this does not help, see video:

http://g.recordit.co/JJ0cmfT1Mb.gif

Here is the sample project: https://drive.google.com/open?id=0B8QGeF3SuAgTNnozX05wTVJGZHc

Screen from sample project to reproduce the issue (there is no code):

How can I apply a friction to a joint to stop rigidbody from moving?

Setting spring with damper or applying a limit is not an option for me, because I need to rotate the rigidbody correctly when I apply enough torque (force) to a motor.
If I switch damper/limit on and off, the rigidbody will move faster when it is rotated in a direction of falling and slower when it is rotated in opposite direction.


texts: Compiling the Latest MonoGame.dll on GitHub

texts:
I've been searching for hours, but still I cannot find "How to compile the latest MonoGame source code from GitHub".

I have tried cloning the GitHub project (develop branch) and I've been looking for the solution that can be used so it will open on Xamarin studio and compile directly, but I have no luck and I don't know if it is the right procedure to get the latest MonoGame library.

Can anyone please help me cite the steps and procedures needed to compile the latest MonoGame source code from GitHub?


texts: What are the different ways to balance an online multiplayer game where user spend different amounts of time online?

texts:
Let's consider a game where every player is building his own medieval town. To make this question simple, let's assume that, on this persistent world, some people will play an hour every day (heavy players), and others will spend an hour per week (light players).

To keep the game fair, a gamer with a lot of free time shouldn't be able to grow much faster than a less present gamer just because he connects more often to the game.

So the first idea is to have a sort of time-based budget: You are saving "action points" as the time is passing. When you connect, you are able to spend this "action points". This way, players are fairly treated...

I see 2 problems:

On one hand, heavy gamers should have the opportunity to play. As often that they want to...
On the other hand, light gamers will be able to connect and make a lot of "actions" in a really short range of "real time" (for instance without been "seen" as the heavy players are..)

So my question is:

What are the solutions that allows light and heavy players to play flairly and balanced regardless of free time to play?


texts: How to stop an animation on last frame until condition is met in Unity?

texts:
I have an animation (fishing) I want to play backwards when the player catches something or cancels the action.

Playing the animation backwards is as simple as setting the speed to -1, ie:

anim.SetFloat("direction", -1.0f);

However, my fishing animation keeps playing until I have caught something, or cancel the animation. This means that the last frame of the animation is showing, but the time of the animation is still going.

So

the animation reaches the last frame
then I stand there for 8 seconds,
I catch something, so I change anim speed to -1
anim will now reverse those 8 seconds I was "standing still" first, before it even reaches the actual animation.

I need to stop the animation time on the last frame (without leaving the animation), so that reverse will be instant. And to not exit the animation until the reverse is finished. Maybe there is some other way to do it, but I can't figure it out.

I could create a seperate animation for when I want it to go backwards, but that seems sloppy.


texts: Can't show an object in a tapped coordinate

texts:
So hi, I have a problem. I want to show an object (Texture2D) in an area tapped by user. This is my fields :

List<Texture2D> list = new List<Texture2D>();
List<Vector2> list2 = new List<Vector2>();
List<int> list3 = new List<int>();

list, is used to store the object. list2, used to store tapped coordinate. and list3, is used to store object timeout (after 100ms, the shown object vanishes)

This is my update method

protected override void Update(GameTime gameTime)
{
    TouchCollection touchState = TouchPanel.GetState();

    foreach (TouchLocation t in touchState)
    {
        if (t.State == TouchLocationState.Pressed)
        {
            list.Add(Content.Load<Texture2D>("base_grass"));
            list2.Add(new Vector2 { X = t.Position.X, Y = t.Position.Y });
            list3.Add(100);

            System.Console.WriteLine("added : " + t.Position.Y + "," + t.Position.X);
        }
    }

    for (int i = 0; i < list3.Count; i++)
    {
        list3[i]--;

        if (list3[i] <= 0)
        {
            list.RemoveAt(i);
            list2.RemoveAt(i);
            list3.RemoveAt(i);
        }
    }
    base.Update(gameTime);
}

(base_grass is the name of my object. It is a plain rectangle image)

The "for" statement is to remove the object when the time expires.

And this is my draw method

protected override void Draw(GameTime gameTime)
{
    GraphicsDevice.Clear(Color.White);

    _spriteBatch2.Begin();

    for (int i = 0; i < list.Count; i++)
    {
        _spriteBatch2.Draw(list[i], list2[i], new Rectangle(0, 0, 64, 64),
                Color.White, 0, Vector2.Zero, 1f, SpriteEffects.None, 1);
    }
    _spriteBatch2.End();

    base.Draw(gameTime);
}

Nothing shown when I clicked on the screen.

But if I change the _spriteBatch2.Draw into this

 _spriteBatch2.Draw(list[i], new Vector2((64 * 0),(64 * i)), new Rectangle(0, 0, 64,64), Color.White, 0, Vector2.Zero, 1f, SpriteEffects.None, 1);

It worked, but shown vertically, not on the tapped / clicked coordinate.

Anyone know where my problem is? Thanks


texts:
Recently, I accidently broke my PC controller and I was forced to play Skullgirls using the keyboard. Needless to say, it sucked. Fighting games are the kind of games where a controller is (almost objectively) better to use than a keyboard, just like how keyboard + mouse is better to use for FPS games than a controller. Keyboards just don't allow the same freedom a controller offers for fighting games, especially because of the analog stick.

So while I was getting my *** kicked and (of course) blaming only my keyboard instead of myself, I had an idea: why don't fighting games use the mouse, too? Couldn't the mouse movements be used as the directional input for the special moves instead of the arrow keys? Examples:

Hadouken - quick flick with the mouse into the direction you're facing
Shoryuken - a steep upward curve towards the direction you're facing
Roundhouse kick - a quick circle motion

What are the advantages and limitations using the mouse in such a way? Are there any examples out there? Maybe there are some limitations I'm not seeing right now? To me, this looks like a way to give players the same freedom in fighting games with keyboard + mouse as a controller would provide, so I'm surprised I don't see more fighting games with that control option.


texts:
I'm getting this error with the new Unity Networking (5.1):

Spawn scene object not found for 1
UnityEngine.Networking.NetworkIdentity:UNetStaticUpdate()

This happens in the client, when it connects to the server: the server is file, while the client fails to load the scene. I guess this error means "I failed to load the (online) scene" (which in fact it is the scene number 1), but I've no clue why it does fail.

The server has a custom player spawning function:

public class NetworkDirector : NetworkManager
{
    public override void OnServerConnect (NetworkConnection conn)
    {
        base.OnServerConnect(conn);

        Transform spawnPoint = FindObjectOfType<SpawnPoints>().getNextSpawnLocation();
        GameObject spawned = FindObjectOfType<InstancedElements>().SpawnObjectFree(playerPrefab,spawnPoint);

        FindObjectOfType<CameraFollow>().SetTarget(spawned);
        NetworkServer.AddPlayerForConnection(conn,spawned,0);
    }
}


texts: Google Leaderboards, Reducing the Score of a Player

texts:
I am making a strategy game similar to chess for Android.

I'll be using the Google Leaderboards for rankings.

I want to implement a sort of ranking system, that the player can actually lose score, similar to the one in www.chess.com.

But, from the docs of submitScore():

"The score is ignored if it is worse than a previously submitted score for the same player."

I don't understand how can I implement such a system with Google Leaderboards.. sorry if I'm missing something obvious here.


texts: How much time would it take to make a sprite-based isometric game with customizable characters?

texts:
I've never been good with 3-d models, but I can do sprites. I was hoping I could perhaps make a 2-d isometric game that acts like 3-d. Something like Don't Starve is what I have in mind.

Here's the kind of features I would like to include in games:

Rotatable camera. Don't Starve is obviously sprite-based, but you can rotate the camera. The effect may not look that great, but it allows the game to work like it has 3-d graphics when it doesn't.
Customizable character. You choose what your character looks like, such as their clothing, hair style, skin color, maybe their face. The issue is, I also want my characters to be animated. I know the number of sprites I'd have to make for that would be huge, but I figured I could shorten the process with things like palette swapping and reversing sprites. Could I have the game procedurally generate a sprite from multiple parts that are all animated? Or would I have to have every single possible combination pre-rendered? Yeah, I'd still have to make a huge number either way, but I can still cut corners where I can.

And yes, I know having both of these things would require me to create an insane number of sprites, but I'd still like to attempt it, if its possible. Also, I'd like to avoid a pixelated look, if that's doable. And yes, I know that would make creating sprites even more laborious, but gimp makes drawing clean lines rather easy, so I'm not too worried about it.

How long would it take me to create each sprite? With that, I could figure out how long it would take me to craft all of them, if I calculate how many sprites I would need per character.

And yes, thinking about the logistics of it all is immense. Animated, customizable characters in game with a rotating camera, meaning that even static objects would need multiple sprites. And no, I don't intend to include camera pitch. Obviously, I'm pushing the boundaries of what I can do as-is.


texts: CLR Profiler Allocated Bytes and XNA ContentManager

texts:
I've been fighting with XNA ContentManager and memory allocations for some weeks because I'm trying to port my game from XNA (Windows) to ExEn / Monotouch (iphone).

The problem is that after playing a few levels, my game exits unexpectedly on a real iPhone device (not simulator).

Profiling memory usage on Windows with CLRProfile, I found some useful stuff but I also found something I dont understand. If I use 2 ContentManagers (1 for shared assets and 1 for level assets), when profiling, "Allocated Bytes" grows and grows after level through level but Memory consumption measured by Windows Task Manager stays constant (down when I unload the content manager and up again when I load content). Obviously, I contentManager.Unload() when level ends. After a few levels my game exits unexpectedly on an iPhone device.

If I use 1 content manager, "CRLProfiler Allocated Bytes" stays constant on Windows and on the iPhone; I can play the game normally and it doesnt exit unexpectedly. I use the same assets level through level.

It seems like in ios (iPhone) when loading and unloading the same assets, it allocates memory and consumes all device memory, so the ios kill it.

Can anybody explain me how this really works?
I've read quite a bit, but I still don't understand what's going on.


texts: Starting a Java activity in Unity3d Android

texts:
I wrote a small Java activity extension of UnityPlayerActivity similar to what is described in the Unity docs. It has a method for displaying a song picking interface using an ACTION_GET_CONTENT intent. I start this activity using startActivityForResult() and it absolutely kills the performance of my Unity game when it is finished, it drops to about .1 FPS afterwords. I've changed removed the onActivityResult function and even tried starting the activity from inside an onKeyDown event in Java to make sure my method of starting the activity from Unity was not the problem. Heres the code in a basic sense:

package com.company.product;

import com.unity3d.player.UnityPlayerActivity;
import com.unity3d.player.UnityPlayer;
import android.os.Bundle;
import android.util.Log;
import android.content.Intent;

public class SongPickerActivity extends UnityPlayerActivity {

    private Intent myIntent;
    final static int PICK_SONG = 1;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        Log.i("SongPickerActivity", "OnCreate");
        myIntent = new Intent(Intent.ACTION_GET_CONTENT);
        myIntent.setType("audio/*");
    }

    public void Pick() {
        Log.i("SongPickerActivity", "Pick");
        startActivityForResult(myIntent, PICK_SONG);
    }

    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
    }
}

This is causing me a bit more of a headache than it should and I would be thankful for any sort of advice. Does anyone have any experience with using custom activities in Unity Android or any insight on why this is happening or how to resolve this?


texts: Why are some games using some dithering pattern instead of traditional alpha for transparency?

texts:
Recently, I have seen some 3D games (eg: GTA IV)  to use some kind of ordered dithering to simulate transparency / alpha.

The polygons are not transparent as usual, but instead render a dithering texture that gradually switch from left to right to simulate transparency :

The effect is not unpleasant but rather surprising to see at first (vs traditional alpha blending)

Except for the visual aesthetic effect it produce, is there any reason some games do this (better performance, saving bandwidth or any else i do not think about) ?

I have searched on the web but cannot found anything about this technique.


texts: Pygame's rotation methods have crippling issues, but is it me or Python's pygame?

texts:
http://www.youtube.com/watch?v=lNJFxvR6ex8&feature=youtu.be

On rotate and rotozoom, can't find fixes on these on the internet, anywhere.
Basically, the video is showing 4 things in this order:
1. A ring image being rotated with .rotate.
2. A simple image being rotated with .rotate.
3. The ring rotated with .rotozoom.
4. The simple circle rotated with .rotozoom.

The difference: In 1 and 2, the images do not have that slight quiver/movement, but are reduced in quality. It might be difficult to tell with the video quality, but the ring image is slightly pixelated/blurred.
                In 3 and 4, the images are of equal/better than 1&2 quality when rotated with rotozoom, but they have this VERY SLIGHT but noticeable wobble about them. This is VERY noticable with test 3, where I put my mouse next to the circle outline, and you can see it move.

ANY and all help will be greatly appreciated, AND this will help many people for a long time, i'm sure.

Here are images of the differences in picture quality of rotate vs rotozoom:

http://s189.beta.photobucket.com/user/ECSit/library/PyGame%20and%20Python


texts: Iterating 1D array and getting 2D tile position

texts:
I know I'm missing something very obvious here, but I have a 1D array that contains integers.I have a map that is 30 x 30 and the center coordinate is 0,0 (This is actually 3D, but I'm essentially removing the Y-axis). Because of this offset, my loop is from -15 to 14, rather than 0 to 29. Is this incorrect?

I'd like to iterate through the array and if the integer is "1", then I'd like to call AddSphere(x,y,z) with the correct x and z values. How would I get the correct values for x and z? The file is designed to be read left to right rather than left to right, right to left, left to right etc... (although if that's a better approach, I can just change the data to match that style).


texts: Large Scale GIS in a AAA-Quality Game Engine? (Unreal, Cryengine, Unity, Etc.)

texts:
I am working on a new simulation project that requires large scale, real-world terrain and imagery (GIS).  By large scale, I mean that I would like to support databases that cover something on the order of 10,000 square miles that include at least height data and satellite imagery.  Using data of this size also means that the engine must be capable of managing the coordinate systems/projections such that some reasonable precision can be maintained.

To my knowledge OpenSceneGraph is the only graphics engine out there that makes this easy (via paged terrain support, osgEarth, etc.)  However, it would be nice to be able to leverage many of the other great features AAA-quality game engines bring to the table.  (OSG is just a graphics engine, really.  I've been using it for over a decade, but I don't want to be fixed only to what I know.)

I've seen many tutorials online for importing small postage-stamp sized bits of terrain into Unreal.  I haven't seen anything on this scale.

Asked here: "Very large terrains in Unreal-4" there is a link to Unreal's "World Composition" feature.  This seems to shift coordinates around and also doesn't seem geared towards using real-world data.

How can I represent real-world terrain data on these scales in a mainstream game engine?


texts: Noise when using SSLR (Screen Space Local Reflections)

texts:
When I tried to apply reflections to my scene, I ran into the problem of noise:

My fragment shader code:

#version 330 core

uniform sampler2D normalMap; // in view space
uniform sampler2D depthMap; // in view space
uniform sampler2D colorMap;
uniform sampler2D reflectionStrengthMap;
uniform mat4 projection;
uniform mat4 inv_projection;

in vec2 texCoord;

layout (location = 0) out vec4 fragColor;

vec3 calcViewPosition(in vec2 texCoord) {
    // Combine UV & depth into XY & Z (NDC)
    vec3 rawPosition = vec3(texCoord, texture(depthMap, texCoord).r);

    // Convert from (0, 1) range to (-1, 1)
    vec4 ScreenSpacePosition = vec4(rawPosition * 2 - 1, 1);

    // Undo Perspective transformation to bring into view space
    vec4 ViewPosition = inv_projection * ScreenSpacePosition;

    // Perform perspective divide and return
    return ViewPosition.xyz / ViewPosition.w;
}

vec2 rayCast(vec3 dir, inout vec3 hitCoord, out float dDepth) {
    dir *= 0.3f;

    for (int i = 0; i < 20; i++) {
        hitCoord += dir;

        vec4 projectedCoord = projection * vec4(hitCoord, 1.0);
        projectedCoord.xy /= projectedCoord.w;
        projectedCoord.xy = projectedCoord.xy * 0.5 + 0.5;

        float depth = calcViewPosition(projectedCoord.xy).z;
        dDepth = hitCoord.z - depth;

        if(dDepth < 0.0) return projectedCoord.xy;
    }

    return vec2(-1.0f);
}

void main() {
    vec3 normal = texture(normalMap, texCoord).xyz * 2.0 - 1.0;
    float depth = texture(depthMap, texCoord).r;
    vec3 screenPos = 2.0 * vec3(texCoord, depth) - 1.0;
    vec3 viewPos = calcViewPosition(texCoord);

    // Reflection vector
    vec3 reflected = normalize(reflect(normalize(viewPos), normalize(normal)));

    // Ray cast
    vec3 hitPos = viewPos;
    float dDepth;
    float minRayStep = 0.1f;
    vec2 coords = rayCast(reflected * max(minRayStep, -viewPos.z), hitPos, dDepth);
    if (coords != vec2(-1.0)) fragColor = mix(texture(colorMap, texCoord), texture(colorMap, coords), texture(reflectionStrengthMap, texCoord).r);
    else fragColor = texture(colorMap, texCoord);
}

Normal map:

Reflection strength map (only red chanel):


texts: GLSL - Only draw arond point / flashlight effect

texts:
I'm currently trying to achieve a sort of flashlight effect in GLSL. I only want to draw textures within a certain distance of a specified point (the mouse position, for example). Here's a quick example drawing of the effect I wish to achieve:

I've successfully created a shader that checks the position from a certain point to the position of the fragment, and then discards the fragment if the distance is larger than the specified light radius. The frag shader looks like this:

#version 400

#ifdef GL_ES
precision mediump float;
#endif

in vec4 v_color;
in vec2 v_texCoords;
in vec2 v_position;

out vec4 outColor;

uniform sampler2D u_texture;
uniform vec2 u_mousePos;
uniform float u_lightRadius;

void main() {
    float distance = distance((v_position + 1.0) / 2.0, u_mousePosition);
    if(distance > u_lightRadius) {
        discard;
    }

    outColor = v_color * texture2D(u_texture, v_texCoords);
}

The problem with this shader is that the visible area isn't a circle, it's an elipse. This is obviously because the screen aspect ratio is not 1:1. I've tried multiplying the Y values of all of the position variables with a resolution uniform, but it still remains an elipse.

My other problem is that I wish to have smooth edges on my visible area. I've read up some on the subject and I see that you can use mix and/or smoothstep to achieve this, but I'm unsure on how to implement it.

Anyone got any suggestions?


texts: Graphics.drawImage will only fill a small portion of my control

texts:
I'm trying to create a map class for a simple 2D game. The map has an array(100,100,5) of string, returning the kind of tiles to draw ( with 5 possible layers from 0 to 4) players will move on the 2nd layer, the background of the game is on layer 0)

I'm want a drawMap sub that I would be able to call as needed. ( not the onPaint method, because I'm loading the game data map from  a binary file, and this game contains the needed coordinates, number of tiles, etc and the array of tiles, so I need to load the map info 1st, then use the draw sub)

I'm struggling right now because only the Tiles(0 to 3, 0 to 1,0) are showing ... while my array is full of tiles  !

Heres the code :

Public class Map
   inherits Panel

'... properties and stuff ....'

 Public Sub New(Optional ByVal mapName As String = "")

    G = Me.CreateGraphics()

    Me.BorderStyle = Windows.Forms.BorderStyle.Fixed3D
    Me.Location = New Point(250, 50)

    Load(mapName)

    Me.Width = mapSizeX * tileSize
    Me.Height = mapSizeY * tileSize

End Sub

Public Sub DrawGraphics(ByVal layer As Integer, ByVal g As System.Drawing.Graphics)
    For y As Integer = 0 To Map.mapSizeY - 1
        For x As Integer = 0 To Map.mapSizeX - 1
            If Not Map.Tile(x, y, layer) = "" Then
                GetSourceRect( x, y, layer, Map) 'return rectangle from my spritesheet '
                dRect = New Rectangle((x * tileSize), (y * Map.tileSize), tileSize, tileSize)
                g.DrawImage(SpriteSheet, dRect, sRect, GraphicsUnit.Pixel)
            End If

        Next
    Next
End Sub
end class

Load(mapname) deserializes a binary file containing the value for mapSizeX and mapSizeY, as well as tileSize and the Tiles(100,100,5) array all filled up.

What am I doing wrong at this point ?


texts:
So far i've been trying to make a RTS in pygame but, i feel like 2d is not enough and pygame has me do a lot of stuff that i would not like doing. What i would like doing is working on the AI gameplay and such and not worying too much about how to display stuff,physics and the like too much.

So far Unity has boo which is supposed to be similar to python i wonder if that could work. How similar is it to python should i use this?
Other options as far as i can see are ogre3d python bindings and UDK.

Which would best suit my needs?


texts: Issues with Flashlight Handle position with player rotation

texts:
I want the flashlight to look same while looking up and down as when looking straight.

Normal Position for Hand and flashlight:

Looking up and down, position is completely off:

More images for character/camera prefab rotation:

Basically the position of the Hand held flashlight changes when I look up or down, as well as the arm stretches. How do I fix this?

Code for character rotation:

private void CharacterRotation()
{
    float posX = Input.GetAxis(mouseX) * ((StructsInitializers.Sensitivity * 5) + StructsInitializers.Sensitivity*50) * Time.deltaTime;
    float posY = Input.GetAxis(mouseY) * ((StructsInitializers.Sensitivity * 5) + StructsInitializers.Sensitivity*50) * Time.deltaTime;
    yAxisClamp += posY;

    if(yAxisClamp > 90.0f)
    {
        yAxisClamp = 90.0f;
        posY = 0.0f;
        ClampYAxisRotation(270.0f);
    }
    else if(yAxisClamp < -90)
    {
        yAxisClamp = -90.0f;
        posY = 0.0f;
        ClampYAxisRotation(90.0f);
    }
    transform.Rotate(Vector3.left * posY);
    PlayerBody.Rotate(Vector3.up * posX);
}

private void ClampYAxisRotation(float value)
{
    Vector3 eulerRotation = transform.eulerAngles;
    eulerRotation.x = value;
    transform.eulerAngles = eulerRotation;
}

PS: I am new to game developing. I have lack of experience.


texts: Libgdx Particle Editor: Blank UI elements

texts: How can I get Libgdx Particle Editor to run properly on my 32-bit Windows 7 machine? When I run it, the UI elements are blank like this:


texts:
Let's say I want to make a character (an animal) with a stick in its mouth.

I dont understand if the animation (done in Blender) should have the stick in its mouth or if it should be done in Unity/Shiva, etc.

Is there any place where I can read the theory behind it? How shall I do interaction between two objects like an animal eating something?

Thank you


texts: How can I associate a key_callback with a wrapper class instance?

texts:
I'm trying to wrap my GLFW3 calls into a single class:

class WindowManager {
private:
    GLFWwindow* window_;
    GLFWmonitor* monitor_;
    Keyboard* keyboard_;
...
}

And I'm trying to setup a singleton keyboard class that collects the keys presses during execution. In GLFW I can set a key_callback function that is outside the class definition (a free function):

WindowManager::WindowManager() {
    ...
    glfwSetKeyCallback(window_, key_callback);
    ...
}

// not a class function
void key_callback(GLFWwindow* window, int key, int scan code, int action, int mods) {
    ...
}

How can I associate my callback and my WindowManager instance so that I can set the keyboard_ object values? I cannot make the key_callback a member function of WindowManager because that would not work since that function would be a member of the the WindowManager class and in C++ member function of a class get their names dangled.


texts: I want that my ship shoots beam after every 2 seconds. How do I make that happen? and also I want that after 50 shots I want to give 10 seconds to reload the gun. I know both of my problems can be solved by gameTime.ElapsedGameTime but how should I use it?


texts:
A Native Collection has not been disposed, resulting in a memory leak. Enable Full StackTraces to get more details.
In working on saving to file the NativeArrays used to fetch BlendShapeCoefficients in ARFoundation, I encountered the error above.
How does one enable the type of full stack trace this error requires to decipher where things went wrong?

I tried the full stack checkboxes on the bottom of Player Settings, but it still does not reveal further details.
I have tried to .Dispose() both upon beginning a new recording and on saving. Calling .Dispose led to another error InvalidOperationException: The NativeArray has been deallocated, it is not allowed to access it
I also tried using brackets [DeallocateOnJobCompletion] above the NativeArray variable declarations (still occurs)


texts: Unity for loop: (List) Argument out of range

texts:
I am attempting to copy the contents of one list into another. On the first iteration I get an "Argument out of range" error.

static List<Building> SaveBuildings(List<Building> buildings)
{
    if (buildings.Count == 0)
        return null;
    Debug.Log("Save Buildings Count: " + buildings.Count);
    List<Building> records = new List<Building>();
    for (int i = 1; i < buildings.Count; i++)
    {
        Debug.Log("i: " + buildings[i].name);
        records[i] = buildings[i].GetRecord();
    }
    return records;
}

The offending line is: records[i] = buildings[i].GetRecord();

This code "Debug.Log("Save Buildings Count: " + buildings.Count);" shows that the list is not empty. The following code "List records = new List();" instantiates a new list to be used.

My understanding is that everything should work well, but when I run the code this line fires "Debug.Log("i: " + buildings[i].name);" and then the error.

I've changed "int i" to be "0" and "i < buildings.Count" to "i <= buildings.Count" with i being 1 and 0. Same results.

I need fresh eyes to find the error lol thank you for your help


texts: SetFloat() in HLSL shader (effect) has no effect - variables stay at 0

texts:
I have a problem wherein I'm trying to set two simple float variables in my shader.  I have a dozen other shaders in this project where it works fine, but for some reason, I've got a bug in this one that I just can't spot.

Here's what I'm doing; I'll edit it down for brevity but try to stay complete.  Any suggestions are very welcome!

First, I store the video width and height in the class that represents my shader, and then call functions that set the variables.

    _hVideoWidth           = _ptrEffect->GetParameterByName(0, "videoWidth");
    _hVideoHeight          = _ptrEffect->GetParameterByName(0, "videoHeight");

    pShader->_videoWidth  = pCameraManager->_backBufferWidth;
    pShader->_videoHeight = pCameraManager->_backBufferHeight;
    pShader->SetActive();

    _ptrEffect->SetFloat(_hVideoWidth,  _videoWidth);
    _ptrEffect->SetFloat(_hVideoHeight, _videoHeight);

Then I do my drawing:

    UINT cPasses;
    pShader->GetEffect()->Begin(&cPasses, 0);
              // Drawing code here
    pShader->GetEffect()->End();

My shader will use the videoHeight/Width in order to scale it to the viewport.  If I hardcode the width and height, it all works perfectly.

cbuffer VideoData : register(b0)
{
    float    videoWidth;
    float    videoHeight;
}

VertexShaderOutput UILineVertexShaderFunction(VertexShaderInput input)
{
        VertexShaderOutput output;

    output.Position = input.Position;

    // Convert pixel coords to (-1, +1)

    output.Position.x = output.Position.x / videoWidth  * 2.0f - 1.0f;
    output.Position.y = output.Position.y / videoHeight * 2.0f - 1.0f;
    output.Color    = input.Color;

    return output;
}

The mystery, however, is that at this point the shader has videoWidth and videoHeight still as zero.  If I just hardcode those two expressions to 1280 and 1024 respectively, it works perfectly.

So, there's SOMETHING about the way I'm setting the videoWidth and videoHeight.  I've confirmed that at the point I call SetFloat() they are in fact passing in the right values, but they just never seem to make it to the shader variables.

Any suggestions or anything obvious?  Even a guess would help, I've been looking at this one for a while!

Thanks,
Dave


texts: Bank ship left/right based on virtual joystick

texts:
I have a 3D game in Unity with a top-down camera view centered directly above a space ship. The ship always stays in the center of the screen, but it allows you to orbit a planet freely using an on-screen joystick. The movement around the sphere is working great, and the camera and ship both move together to orbit the planet.

With that being said, I would like to "bank" the ship left and right as you turn to add a more realistic flight affect. At most the ship will bank 45 degrees to either side, but the amount will be based on how hard they are turning which will come from the joystick as well (distance joystick is from its origin).

I'm having trouble figuring out a good formula for this rotation. I have tried many different things with varying results, but my thought was that I would determine which way the ship is turning first, either left or right. Then apply a hard coded 45 degree angle for now to the y-axis. This actually gets me mostly there. But it seems I need to flip this to the x-axis at times, and when the ship is flying in the opposite direction (pointing down) it seems everything gets mirrored? As you can see, I'm confused haha. Does anyone have any insight as to a better approach, or if you can see issues with my current approach? Thanks!

Here is a bit of code that I have tried:

The update method to apply the rotation:

public void Update()
{
    TurningDirection turningDirection = GetTurningDirection(); // See below for this
    float direction = turningDirection == TurningDirection.Left ? 1f : -1f;
    bankRotationAngle = 45f * direction;

    // Using 45 degrees here for now, but will eventually change this to come from the joystick as well to get the correct amount to bank based on how hard they are turning
    if (Mathf.Abs(bankRotationAngle) > 45f)
    {
       bankRotationAngle = 45f * direction;
    }

    transform.localEulerAngles = new Vector3(transform.localEulerAngles.x, bankRotationAngle, transform.localEulerAngles.z);
}

The GetTurningDirection method (this is based off an angle to capture their last/current angle to see if the ship is turning left or right):

 private TurningDirection GetTurningDirection()
 {
     // If it hasn't changed, return the current direction
     if (joystickAngle == lastJoystickAngle)
     {
         return turningDirection;
     }

     if (joystickAngle < lastJoystickAngle)
     {
         return TurningDirection.Left;
     }
     else
     {
         return TurningDirection.Right;
     }
 }


texts: How to display a text in the impact point position

texts:
In my 3d game, i would like to display a text 'near' the impact point of a bullet.
I think i'm having problems setting properly text position.
This is my code.
The script is attached to an object Canvas.
position is the Vector3 impact position.

GameObject obj = new GameObject ();
Text _text = obj.AddComponent<Text> ();

_text.transform.position = position;
_text.text = message;
_text.fontSize = startSize;
_text.color = color;

I'm pretty sure i've to convert from a world space to a 'user interface' space.
Thanks


texts: How to prevent players from using save/load tactics in Roguelike games?

texts:
Players can achieve the expected results through continuous saving and loading in rogue-like games.

I am try to reduce this method as much as possible, but don't want to keep players from trial and error at all, which makes the game more difficult.

Anybody could give me some advice in this respect?


texts:
I've already implemented collision detection in my game loosely following this tutorial, which works great, but I realized there's one major flaw.
The player and the enemies are circles, while the obstacles can be either segments or polygons or circles.
Now, let's say I have segment A from point (100, 100) to point (300, 100) and segment B from point (100, 200) to point (300, 100), which means they form an acute angle, and player has it center in point (100, 125), with a radius of 25.
If player starts moving right, it will eventually collide against segment B. My method checkCollisions() will return a vector, but if I apply that vector on player, it will be moved up and left, and will overlap segment A.
If I call checkCollisions() a second time, player will be pushed down and collide again with segment B, so recursive invocations aren't a solution. Any ideas?

Here's a picture to explain:
 The g->n vector direction is along the bisector of the two little vectors, but how do I find the length?


texts: Get Unity to read in objects name without the need to hard code

texts:
I'm trying to get away from having to hard code in the names of objects I want my code to use.

For example, I'm use to do it this way:

    TextAsset test = new TextAsset();
    test = (TextAsset)Resources.Load("test.txt", typeof(TextAsset));

What I want to know, is there a way to have so that when I drag my test.txt file onto my object in Unity, my code automatically gets the name of that object?

I'm wanting to do this so once I write the code, I don't need to back in and change it should I wish re-use it.


texts: HTML5 point and click adventure game code structure with CreateJS

texts:
I'm a programming beginner.

I made a tiny one scene point and click adventure game to try to understand simple game logic and came up with this:
CreateJS features prototypes for creating bitmap images, sprites and sounds objects. I create them and define their properties in a corresponding function (for example images(); spritesheets(), sounds()...). I then create functions for each animation sequence and "game level" functions, which handle user interactions and play the according animations and sounds for a certain event (when the level is complete, the current level function calls the next level function). And I end up with quite the mess.

What would be the "standard (if something like that exists)" OOP approach to structure simple game data and interactions like that?

I thought about making game.images, game.sprites, game.sounds objects, which contain all the game data with its properties using CreateJS constructors. game.spriteAnimations and game.tweenAnimations objects for sprite animations and tweens and a game.levelN object, which communicates with a game.interaction object, processing user interaction. Does this make any sense?

How do you structure your simple game code?
Thanks in advance!


texts: Calculate position given velocity and acceleration at a given timestep

texts:
I am following a Pixar course at Khan Academy and I came across a simulation of a double spring with a given timestep. I understand how it works and why it behaves the way it does, but I want to know if the math is actually accurate. What I'm interested in is the following lines:

 // Mass 1 velocity
 mass1VelocityY = mass1VelocityY + mass1AccelerationY * timeStep;
 mass1VelocityX = mass1VelocityX + mass1AccelerationX * timeStep;

 // Mass 1 position
 mass1PositionY = mass1PositionY + mass1VelocityY * timeStep;
 mass1PositionX = mass1PositionX + mass1VelocityX * timeStep;

So we first calculate the velocity, adding a fraction of the calculated acceleration to it, and then we calculate the position, adding a fraction of the calculated velocity to it. So we are building the final position at time T by summing T/timestep intermediate positions.

Given the formula for displacement s=ut+0.5at^2 where:

s = displacement
u = initial velocity
a = acceleration
t = time

If I plug in the values: s = 0, u = 0, a = 1, t = 2, I will get s = 2. That means that if I start at position zero and I build up the velocity with an acceleration of 1m/s/s I will end up at position 2, with a velocity of 2m/s.

Now if I try to follow the same logic but break that result into 20 steps(2/0.1 - t = 2 timeStep = 0.1), and sum the results of all these intermediate steps as is being done in that code, I will get a different result: s=0.55 at t=1 and s=2.1 at t=2.

My initial intuition is that because in the code we end up multiplying timeStep by acceleration twice, it becomes exponentiation and so the progession isn't linear anymore and so smaller steps will get smaller values in the beginning. So I have 3 questions:

1) Did I understand what the code is doing correctly?

2) Is what the code is doing the most correct/accurate way to calculate displacement?

3) I really want to grasp these concepts so if you have any other advice or know of something that would be helpful for me to learn, please point me to it.


texts: How To Resize Existing Texture In OpenGL 4.3

texts: I would like to know how to resize an existing OpenGL 4.3 texture while keeping the current contents.  i'm using glTexImage2D().  Do I simply re-call glTexImage2D() with nullptr for the data paramater?


texts: OpenGL sprites and point size limitation

texts:
I'm developing a simple particle system that should be able to perform on mobile devices (iOS, Andorid). My plan was to use GL_POINT_SPRITE/GL_PROGRAM_POINT_SIZE method because of it's efficiency (GL_POINTS are enough), but after some experimenting, I found myself in a trouble. Sprite size is limited (to usually 64 pixels). I'm calculating size using this formula

gl_PointSize = in_point_size * some_factor / distance_to_camera

to make particle sizes proportional to distance to camera. But at some point, when camera is close enough, problem with size limitation emerges and whole system starts looking unrealistic. Is there a way to avoid this problem?

If no, what's alternative? I was thinking of manually generating billboard quad for each particle. Now, I have some questions about that approach.

I guess minimum geometry data would be four vertices per particle and index array to make  quads from these vertices (with GL_TRIANGLE_STRIP). Additionally, for each vertex I need a color and texture coordinate. I would put all that in an interleaved vertex array. But as you can see, there is much redundancy. All vertices of same particle share same color value, and four texture coordinates are same for all particles. Because of how glDrawArrays/Elements works, I see no way to optimise this. Do you know of a better approach on how to organise per-particle data?

Should I use buffers or vertex arrays, or there is no difference because each time I have to update all particles' data.

About particles simulation... Where to do it? On CPU or on a vertex processors? Something tells me that mobile's CPU would do it faster than it's vertex unit (at least today in 2012 :).

So, any advice on how to make a simple and efficient particle system without particle size limitation, for mobile device, would be appreciated.

(animation of camera passing through particles should be realistic)


texts: Isometric rendering code is not rendering correctly

texts:
I'm trying to render some tiles in an isometric view, I'm using Java with the Slick2D library.

float xoff, yoff;
int half = 64;

public void render(GameContainer gc, StateBasedGame sbg, Graphics g) throws SlickException {
    for (int x = 0; x < width; x++) {
        for (int y = 0; y < height; y++) {
            int xa = (x * half) - (y * half);
            int ya = (y * half) + (x * half);
            xa -= xoff;
            ya -= yoff;
            tiles[x + y * width].render(gc, sbg, g, xa, ya);
        }
    }
}

Basically I'm iterating through a 2d array of tiles (the tile is just a class with the render method), the xa and ya being passed will draw an image at that exact co-ordinate, there isn't much going on in the render method. The thing that seems to be messing up is the math for making it render in an isometric view, it kind of works, but the tiles look like bricks because it's not pushed down more on the y axis.

Am I doing something wrong in my rendering that will cause this behaviour shown in the image? The tiles heigh is too skinny, but the tiles are overlapping and aren't being pushed down far enough.

The image might look like it's working, but the tile is actually 128x128, but it's rendering like it's 128x64.


texts: How do I determine color resolution of an output in DXGI/D3D?

texts:
i'm was revising some code i wrote some time ago when working on the window wrapper for my rendering framework. The framework is based off DirectX, but it wasn't really using any D3D-related facility. Instead it was wrapping the EnumDisplaySettings call :

DEVMODE dm;
dm.dmSize = sizeof(dm);
int_32 count{ 0 };
while (EnumDisplaySettings(NULL, count, &dm))
{
    if (dm.dmPelsWidth == _width && dm.dmPelsHeight == _height)
    {
        m_width = dm.dmPelsWidth;
        m_height = dm.dmPelsHeight;
        m_color_resolution = dm.dmBitsPerPel;
        m_display_frequency = dm.dmDisplayFrequency;
        return true;
    }
    ++count;
}

Simple as that, this doesn't take into account the format. It does take the refresh rate in count (DisplayFrequency) that I've supposed being the same thing. I'm using this Win32 call because later whenever someone needs to set the window to fullscreen I apply the DEVMODE through ChangeDisplaySettings().

I could have used the IDXGIAdapter::EnumOutputs call, but this doesn't give me the bits per pixel (or color resolution). I've done some tests and its value is 32 most of the times but I don't want to take it for granted. My question(s) is(are):

Is there any way to get the color resolution through Direct3D ? is it strictly related to the format ?
Is my approach correct at all ? because i'm having some doubts, should i keep using the Win32 calls or use the D3D ones ?

I apologize if this question has already been answered or if it has an obvious answer that I can't get, I bet I'm missing something.


texts: what algorithms exist for combining multiple triangle meshes into one mesh

texts: Let's say I have a terrain mesh of some triangles, and several smaller meshes which I want to add to that terrain mesh (think ground and some small mounds or berms for example). What would I look for to find algorithms to let me do this? I know it's like some kind of computational geometry but I wonder if anyone might know search terms or even better urls to look at. Ideally I would like to do this on the fly to simplify drawing of a terrain where the basic ground and the detailed "interesting" bits are stored separately. Right now we draw the ground and the other parts separately which is less than ideal.


texts: Create a variety a sprites from a single image in XNA?

texts: I want to be able to take a single image and cut them up into a lot of images to make the sprites. How would I do that in XNA since I only know how to load the texture then use it without changing it?


texts: How do i make a list of generic classes?

texts:
First of all, I want mods in my game, as stated in a previous question, I want to do that via registries. Users make content known to the game in the form of 'Registering' it, then it can be used in several other stuff. Registering a block to have it appear on the terrain is one example.

Registering is done in the form of events, where each registry has an OnEntryCollection event with a list where other classes subscribe to in order to add Entries, and then it gets invoked to gather said entries.

Basically I have a registry system, where there's a large meta-registry(The Game-registry) that has a list of smaller Registry<T> registries, each dedicated to a type (a block, an item, etc). I want to be able to add to these registries via a Registry.Add(T obj) method, but I'm not exactly sure how to do that because in order to store them I had to use an empty interface I made (IRegistry).

This is meant to be a way for me to add Entries in through code, from specific files I parse in, while also allowing modders to add in custom content through registry events I will add later. Nothing is meant to be added in through the inspector, rather registered in through events.

My code:

Game-Registry:

[SerializeField] List<IRegistry> registries = new List<IRegistry>();

Registry :

public class Registry<T> : IRegistry where T : IRegistryEntry {
    Dictionary<ResourceLocation, T> EntryDictionary = new Dictionary<ResourceLocation, T>();

    public delegate void registryAdditionHandler(List<T> entries);
    public event registryAdditionHandler OnRegisterAddEntries;

    ResourceLocation keyName;

    public Registry(ResourceLocation keyName) {
        this.keyName = keyName;
    }

    public void Register(T entry) {
        EntryDictionary.Add(entry.GetRegistryName(), entry);
    }
    public void Remove(ResourceLocation loc) {
        EntryDictionary.Remove(loc);
    }

    public T Get(ResourceLocation key) {
       return EntryDictionary[key];
    }
    public int Count() {
        return EntryDictionary.Count;

    }

    public bool ContainsEntryKey(ResourceLocation key) {
        return EntryDictionary.ContainsKey(key);
    }
    public bool ContainsEntryValue(T value) {
        return EntryDictionary.ContainsValue(value);
    }

    public bool TryGetValue(ResourceLocation key, out T value) {
        if (EntryDictionary.TryGetValue(key,out value)) {
            return true;
        }
        return false;
    }

    public ResourceLocation getRegistryName() {
        return keyName;
    }
}

IRegistry interface:

public interface IRegistry  {
}


texts: Unity graphics lagging and leaving a trail

texts:
The following are pictures of what I am describing. This happens both when I have normal lighting, graphics on low, render distance on short. I have a graphics card that can run games like Starcraft II easily. It appears to be the top of the screen that is most often affected by this lag. The lag is also seen on terrain. It happens when I build and set quality to low as well. Even if I change the camera angle. Camera movement is irrelevant. Although I am using position to make the camera not momentum. Any idea what might be causing this?

And the following is what it cuts to when the renderer catches up:

It only appears when the background is either not rendered, or very far in the distance.

Yes I have tried restarting unity, yes I have restarted my computer.

Here is the image with the camera settings:


texts: How to automatically select a graphical quality level?

texts:
I'm making a game that lets the users choose their graphical settings, with the usual categories: low, medium, high.
I want to implement an "auto" category, and decide what the appropriate values are on startup. But I'm not sure how to do that.
For example in OpenGL, you could check the OpenGL version or query the memory through extensions (if provided) to guess at it, but that seems fickle since it may be the case that a low end graphics card has a high OpenGL version but bad hardware. Checking memory might be a bit better, but I assume it still is not the most accurate way of checking things.
A more robust approach would be to render in the background and check the FPS, but that could require setting up a whole scene, rendering it, etc. Most games seem to do this very quickly, so I don't know how they could set up a whole scene and do a bunch of quick tests.
Is there a fast way to do this?


texts: How would I get the positon of my avatar's head?

texts: I'm developing an XNA Game. Basically, I have a first person camera. What I want to do is get the position of an avatar's head. The reason I want to do that is because I want the camera to be on the avatar's head thus, giving it a real life view (you can see the hands and that type of stuff.


texts: Still i can't make the cross hair to be in the middle of the screen, What am i missing?

texts:
In the editor i did:

GameObject > UI > Image

On the Canvas i changed the Render Mode to Screen Space - Camera.

It created a Canvas and a child Image in the Hierarchy.
Then i changed the Image source to UISprite changed the color to red also added to it a material in red.

I can't changed the Canvas anchors not sure why.

The Image rect transform anchors is set to the center.

I don't have a Main Camera the only camera i have is on the FirstPersonController (The FirstPersonController is a child of a FPSController).

But still the red dot/circle is a bit to the left not in center.

Screenshot of the Canvas:

And two screenshots of the Image:

And


texts:
I'm currently writing a game in XNA for fun which uses C#.  I have got my sprites loaded and when the character moves right he looks like he is running right and when he moves left he looks like he is running left.

I been looking everywhere for a good coding example for how to create a jumping ability.  I have read all the physics stuff that I can stand and it doesn't help when I can't figure out how to use say space bar to jump yet can't keep them from using space just jump again until they land.


texts: Calculate required position to keep object centered when camera is rotated

texts:
I always want to keep an object in the center of view of a camera.
When the camera's rotation X value is -45, the object should still be centered.

Therefore I need to calculate the new position of the camera.

How could the "required camera position Y value" be calculated?

Thank you.


texts: how to reference a variable in an anothere script

texts:
i have a object which sets pickedup = true on collision
public class IDCARD : MonoBehaviour
    {
    private bool pickedup = false;

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

    }

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

    }

    private void OnCollisionEnter(Collision collision)
    {
       print("k");
        pickedup = true;
        Destroy(gameObject);
    }
}

now i want exit script in an another object to check if pickedup == true on collison
now what can i do pls  give a brief explanation  with a names i have given
i have written your code. but i think there is some issues


texts: Entity Component System: Store pointer in Component to Entity

texts:
I was wondering if it is a bad idea to store a pointer in every Component to the Entity which owns the Component.

E.g. I have a Component "NPC". Each entity which owns this Component also must have a Position and Sprite Component. Sometimes i get a list of NPC Components from one of my Systems, but I also need the coresponding Position and Sprite Components. I can retrieve the entity, but it's quite some code I have to type and it is more expensive than just following the pointer.

So would it be a bad idea to store a pointer to the Entity in a Component?


texts: How to port a Skyrim Legendary Edition mod to Skyrim Special Edition, and vice-versa?

texts: There are a lot of mods I want to port, but I don't know how to go about it and do it properly to avoid crashes, etc. Could you put all of the steps and relevant information here so I can use it as a future reference? I am trying to port a major mod with scripts, 3d models, new items, new spells and whatnot.


texts: I have a problem rotating a 2D game object after collision

texts:
I'm developing a simple flip game where a cube flips and the bar a it collides with should start rotating after collision. Most snips involve destroying an object, but that's not my case.

Here is my code:

using UnityEngine;

public class CheckI : MonoBehaviour
{
    float x;
    public Rigidbody2D rb2d;

    void OnCollisionEnter2D(Collision2D col)
    {
        if (col.gameObject.tag == "bar")
        {
            x += Time.deltaTime * -10;
            transform.rotation = Quaternion.Euler(0, 0, x);
        }
    }
}

How do I start rotation after collision?


texts: I want to clamp each instance of the same prefab to the y axis only

texts:
I instantiated the prefab "paddle" twice then I tried clamping it to the y-axis only; using Mathf.Clamp, however, the min and max values end up being applied to both instances of "paddle" and hence they can move in the x-axis

ok so I'm trying to make a 2d mobile pong game, I have a prefab "paddle" which are the rackets/bats which the balls collide with.

I instantiated the same prefab twice one on each side of the screen :

Paddle paddle1 = Instantiate(Paddle) as Paddle;
Paddle paddle2 = Instantiate(Paddle) as Paddle;
paddle2.Init(true); //right paddle
paddle1.Init(false); //left paddle

Now i want each of the paddles to only be able to move in the y axis (UP And DOWN).

So I tried clamping them with:

var poss = transform.position;
poss.x =  Mathf.Clamp(transform.position.x, -1.0f, 1.0f);
transform.position = poss;

However, this caused the left paddle to still be able to move to the right and the right paddle to be able to the left( I don't want them to move in the axis at all).

This is the file GameManager.cs:

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

public class GameManager: MonoBehaviour
{
    public Ball Ball;

    public Paddle Paddle;

    public static Vector2 topRight;
    public static Vector2 bottomLeft;

    // Start is called before the first frame update
    void Start()
    {
        bottomLeft = Camera.main.ScreenToWorldPoint(new Vector2 (0,0));
        topRight = Camera.main.ScreenToWorldPoint(new Vector2
        (Screen.width,Screen.height));

        Instantiate(Ball);

        //Paddle paddle1 = Instantiate(Paddle) as Paddle;
        Paddle paddle1 = Instantiate(Paddle) as Paddle;
        Paddle paddle2 = Instantiate(Paddle) as Paddle;
        paddle2.Init(true); //right paddle
        paddle1.Init(false); //left paddle
    }

    void Update()
    {

    }

}

This is the file paddle.cs:

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

public class Paddle : MonoBehaviour
{
    Rigidbody2D rb;
    float directionY;
    float speed;
    float height;

    float distance;
    string input;
    bool isRight;

    // Start is called before the first frame update
    void Start()
    {
        height = transform.localScale.y;
        speed=5f;
    }

    public void Init(bool isRightPaddle)
    {
        isRight = isRightPaddle;
        Vector2 pos = Vector2.zero;

        if(isRightPaddle)
        {
            //Place paddle on the right of the screen
            pos = new Vector2(GameManager.topRight.x, 0);
            pos -= Vector2.right * transform.localScale.x; //Move a bit to the left
        }
        else
        {
            //Place paddle on the left of the screen
            pos = new Vector2(GameManager.bottomLeft.x, 0);
            pos += Vector2.right * transform.localScale.x; //Move a bit to the right
        }

        //Update this paddle's position
        transform.position = pos;
    }

    void Update()
    {
        var poss = transform.position;
        poss.x =  Mathf.Clamp(transform.position.x, -8.0f, 8.0f);
        transform.position = poss;
    }
}

I expect each paddle to not be able to move in the x axis. Only in the y axis

c# unity3d mobile


texts: How can I render all objects behind a plane with a specific transparency value?

texts:
I have a game where there a multiple floor levels between the player switches. The floor is not present everywhere, so you can look through it. When 'working' (playing, building stuff, etc.) on a specific floor I want to add a transparency value to everything that is NOT on the current floor.
Ho can I accomplish that, and what is the best/most efficient way to do that?


texts: XNA Starting a parallel Thread during a draw loop is slower than doing the same task in the main thread in update loop

texts:
I'm using XNA and all of my drawing is done in the main thread. I am CPU-bound and I thought I could gain performance by moving some non-update logic (like animation update) from the update loop into the draw loop and performing it in a parallel thread. This is the pseudocode:

Before:

void Update()
{
    foreach (var model in AllGameModels)
        model.UpdateAnimation();
}

After:

void UpdateAnimation()
{
    foreach (var model in AllGameModels)
        model.UpdateAnimation();
}
Thread UpdateAnimationThread;

void Draw()
{
    if (UpdateAnimationThread != null)
        UpdateAnimationThread.Join();
    UpdateAnimationThread = new Thread(UpdateAnimation);

    [main Draw code follows]
}

Unfortunately this always results in a significant DROP in performance. What can I be doing wrong? There is NO multithreading code in the Draw loop as it is simply impossible to do and I am not missing anything.


texts: How do I query a LibGDX Box2DLights "light" and "dark" regions?

texts:
I have lighting implemented using Box2dLight. I want to update/render things inside the player's PointLight area. Stuff in the dark area should not be rendered.

How can I find which areas are lit or dark?

My PointLights and Body look like this:


texts: Pathfinding in Procedural cave generation

texts:
I'm learning THIS tutorial about procedural cave generation using cellular automata with Unity.

I want to implement pathfinding on some enemies, so I need to make a quantization of the procedurally generated "non-wall" part of the map. Is there a best way to place nodes in this space?

I hope I was clear enough and I'm sorry if not.


texts: Is there a maximum value of sample for Anti Aliasing in Unity?

texts:
In Quality settings, there is Antialiasing option with 2~8x sample range. I can change the sample by script like this:

QualitySettings.antiAliasing = myAAValue;

However is there a maximum value? In Unity Editor, minimum is 2 and maximum is 8.


texts: I can't jump when i press up, and left at the same time

texts:
///Get player's input
key_right = keyboard_check(vk_right);
key_left = -keyboard_check(vk_left);
key_jump = keyboard_check_pressed(vk_space);
key_jump_held = keyboard_check(vk_space);
key_shoot = keyboard_check(ord("D"));

//React to inputs
move = key_left + key_right;
hsp = move * movespeed;
if (vsp < 10) vsp += grav;

if (place_meeting(x, y+1, Obj_Floor))
{
 vsp = key_jump * -jumpspeed;
}

if (vsp < 0) && (!key_jump_held) vsp = max(vsp,0)

//Horizontal Collision
if (place_meeting(x+hsp, y, Obj_Floor))
{
 while(!place_meeting(x+sign(hsp), y, Obj_Floor))
 {
  x += sign(hsp);
 }
 hsp = 0;
}
x += hsp;

//Vertical Collision
if (place_meeting(x, y+vsp, Obj_Floor))
{
 while(!place_meeting(x, y+sign(vsp), Obj_Floor))
 {
  y += sign(vsp);
 }
 vsp = 0;
}
y += vsp;

//Animate
if (move != 0)
{
 image_xscale = move;
}

if (place_meeting(x, y+1, Obj_Floor))
{

 if (move != 0)
 {
  sprite_index = CalvinWalking;
  image_speed = 0.07;
 }

 else
 {
  sprite_index = CalvinStanding;
  image_speed = 0.025;
 }
}

else
{
 if (vsp < 0) sprite_index = CalvinJumping
 else sprite_index = CalvinJumping
}

and

///Shooting with D
//Shooting direction
if (keyboard_check(vk_right))
{
 mpfacing = 0;
}

if (keyboard_check(vk_left))
{
 mpfacing = 180;
}

if (keyboard_check(vk_up))
{
 mpfacing = 90;
}

//Shooting
if (keyboard_check(ord("D"))) && (canshoot = true)
{
 instance_create(x+13, y-0.5, Obj_MP_Laser);
 canshoot = false;
 alarm[1] = 30;
}

is my code but for some reason when i press up, and move left, i can't jump when i press space. Which i don't understand because i can jump when moving left, and when i press up, but not when i press both.


texts: Tile based map and collision; getting stuck

texts:
I'm trying to make my character move around a tile map with collisions. Everything works fine except for one thing. I show you a picture with the problem:

http://i.stack.imgur.com/ZWI7x.jpg

That is, when I reach a tile above then I can not move anywhere. If you come from the left, I can not move either up or down. If you reach the bottom, I can move to the left but not right. And when you reach the right I can move in any direction.

Honestly I have no idea what may be failing. I think it has to do with if (...), because if I change the order,  the addresses where I can move change :/

Here I leave some code:

boolean collision = false;

if(Keyboard.isKeyDown(Keyboard.KEY_UP)) {
    for(int i = 0; i < map.GetNumLayers(); i++) {
        if(UpTile(map, i) > 128) {
            collision = true;
        }
    }

    if(!collision) AddPos(0.0f, -vel);
}
if(Keyboard.isKeyDown(Keyboard.KEY_LEFT)) {
    for(int i = 0; i < map.GetNumLayers(); i++) {
        if(LeftTile(map, i) > 128) {
            collision = true;
        }
    }

    if(!collision) AddPos(-vel, 0.0f);
}
if(Keyboard.isKeyDown(Keyboard.KEY_DOWN)) {
    for(int i = 0; i < map.GetNumLayers(); i++) {
        if(DownTile(map, i) > 128) {
            collision = true;
        }
    }

    if(!collision) AddPos(0.0f, vel);
}
if(Keyboard.isKeyDown(Keyboard.KEY_RIGHT)) {
    for(int i = 0; i < map.GetNumLayers(); i++) {
        if(RightTile(map, i) > 128) {
            collision = true;
        }
    }

    if(!collision) AddPos(vel, 0.0f);
}

public int UpTile(Map map, int layer) {
    return map.GetValue(layer, (int) (x/size), (int) (y/size));
}

public int LeftTile(Map map, int layer) {
    return map.GetValue(0, (int) (x/size), (int) (y/size));
}

public int DownTile(Map map, int layer) {
    return map.GetValue(layer, (int) (x/size), (int) (y/size + 1));
}

public int RightTile(Map map, int layer) {
    return map.GetValue(layer, (int) (x/size + 1), (int) (y/size));
}

public int GetValue(int layer, int x, int y) {
    return array[layer][y][x];
}

The map is an array with 3 componentes: [LAYER][Y][X]. So, in RightTile by example, with GetValue, I'm getting the value from the array in the position [layer][y/size][x/size + 1], x/size + 1 because I want to get the kind of tile that is to my right (same with the others). size = 64, that is the width and height of each tile.

Thanks >.<


texts: Pixel-art sprite distortion with 1:1 pixel ratio

texts:
So I've been studying the Unity's PPU, pixel density, camera settings topic to make my game pixel-perfect. I've set everything in a way that my screen pixel to sprite texel ratio equals 1.

The art looks very good and crisp overall on the game view...

But!

There are still some minor distortions and I don't know where it comes from.

Take a look at this example:

In this example my settings are:

Screen: 870x510
PPU: 100
Camera size: 2.55
Pixel snap on Sprite material: on

The issue happens when I move the sprite manually by ~0.001 values on the Y axis. Same happens on the X axis.

Any ideas what's the problem?


texts: LibGDX , Scale button with animation when it is pressed

texts: I am developing game using LibGDX . I want to create beautiful menu and to scale buttons when they are pressed but not in this way , when it is pressed scale it 1.5f , I want to scale it with animation . I am using imagebuttons .


texts: How to attach "exiting" event in OpenFL?

texts:
What is the exiting event (closing app by user or system) in new OpenFL?

And how does it differs between target platforms?


texts: Making enemy boss movement better than just moving randomly

texts:
I am making a game where I have a player spaceship on left side and an enemy spaceship (boss) on the right. I need some ideas on what my enemy should do.

If I move my enemy down and up, down and up, etc.. then the player will be able to predict the enemy's movements. On the other hand, I don't really want the enemy to move randomly. It won't look good if the enemy is just moving to and shooting at random places.

I am also thinking of making my enemy move left, and when it reaches the outside of the screen then coming back in from the right side. Let me know what you guys think.


texts: What is the most efficient way to determine collision path

texts:
I am trying to create a game in which I need to know if two objects will collide in the future, and when. I have both object's position, radius (they are circles) and velocity.

A specific example of where this could be used is in a game with an asteroid field. The asteroids position, radius and a constant linear velocity. I want to determine if on their current trajectory, will they crash. If yes, in how much time.

I have tried to set up the position of the objects as a function of time:
P(t) = o + v(t)

Where P(t) is the new position, o is the original position v is the velocity and t is time.

Using this for both objects and attempting to solve for t, I get a very messy and long equation.


texts: How to avoid the cutoff of a Sprite when overlapping in a terrain?

texts:
I have a scene where I have a terrain as a PlaneGeometry. And I'm trying to locate a building on it as Sprite. But I'm not able to put that building/sprite centered on the terrain without getting a cutoff.

Make sense because the terrain is cutting the half. But I'm just wondering if there is a technique to solve this problem.

I tried to rotate the sprite as a 3D object. But does not have this property. Also tried using a PlaneGeometry with a MeshBasicMaterial, but the result of the Image looks blurry and without transparency.


texts: Painter algorithm vs. 3D rendering with Z-buffer when drawing 2D Sprites

texts:
I'm currently developing a tile base engine. I want it to look like your average old school tilebased RPG like Zelda - Link to the past (orthographic projection, squared tile texture, textures overlapping each other, alpha channels, etc.). The twist is that the world is internally 3d meaning that every tile has an elevation and entities are moving in a 3d space. Reason for this is beyond the scope of this question but I'm struggling on comparing the follow two ideas for the rendering. I'm using OpenGL with libGDX in Java but wouldn't mind writing my own code to interface OpenGL. That's also why I didn't tag it.
A screenshot of "Zelda - Link to the past" in case you don't know what it looks like.

Painter algorithm
Disable Z-Buffer and use painter algorithm to draw from back to front in the appropriate order with some overdraw and a lot of texture rebinding. I know a texture atlas can minimize the texture rebinding but the engine is supposed to act more like a sandbox so I don't want to rely too heavily on assumptions like a efficient texture atlas that I might not have all the time.
Pro: Easy to implement and very straight forward.
Con: I've no idea how big the impact will be since almost every sprite will cause a texture rebinding. And I don't know how to predict the performance costs of that many texture bind calls.

Full blown 3D
Rotate the camera 45 degrees up around the x axis with an orthographic projection matrix. Then use the 3d information from the game world to draw the tile textures with billboarding at the real position in the worlds 3d space. Same for entities and such. This way I can gather all sprites and then render them sorted by their texture which means one texture bind per texture and reduced overdraw due to usage of the Z-buffer
Pro: I can use a freecam to debug render problems. I assume it's significantly faster that the painter algorithm.
Con: Some sprites might share the same place which could lead to Z-fighting. I'm thinking about how to use multiple layers on a tile. For instance you may have a bridge tile with a railing where the railing is always overlapping an entity on the bridge but the floor of it is always overlapped by the entity. So I would have to add a little offset to different layers in the 3d space. I'm not really sure how that would work out and to be honest had a hard time figuring out how old games did it so maybe I'm overthinking it.

I guess I have a very rough idea of how each method will work out but I don't know how much the texture rebinding (or sorting and preparing the sprites for the 3d approach) is affecting the performance and while it's easy to find information regarding large 3D scenes I found it difficult to get information about 2D scenes with way less polygons.I hope this question is not too much a subject of personal preference. I know that Premature optimization is the root of all evil but due to how the decision is affecting almost the entire rendering process I don't want to make the wrong call.
I deliberately didn't mention any OpenGL functions mainly because I've mostly used the libGDX API which hides the function calls behind it's wrappers but generally I know how the internals work and just got into the internals and how the OpenGL API works. I don't think specific OpenGL calls do matter for the question but feel free to use them for your answer I'll just look them up.


texts: Flipping the game so that the local player is always on the left side of the screen?

texts:
I'm making a 1v1 game with each player at one end of the screen. The game is an online client-server game. I would like the local player to be on the left side of their screen and their opponent (the remote player)  on the right side. Similar to Clash Royale where the local player is always on the bottom and their enemy always on top.

What is the easiest way for me to accomplish this?

Some solutions I've thought of so far:

The server checks every time it sends data back to the players that if it's sending the data back to player 2, it flips it before sending it back. I don't particularly like this solution because it will greatly complicate the code, increasing the chances of bugs, and make it less flexible / re-usable in the future.
The client checks if it is player 2 and flips the data it received back from the server if it is. I don't like this solution for the same reasons as above.
Some camera tricks I don't know about.


texts:
I'm developing my 1st board-game (go-game) in C with Allegro 5, for a course project. Part of my goal is to make a gamesave of the current gamestate. Let's say for 2 players if we exit the game, and log in the game, we want to reload the previous gamestate such that the position of the stones by 2 players to be preserved in their positions. How can I achieve this?
I will appreciate any related reference, tutorial, or a git reference I can learn more about saving the states of the game.

P.S. I checked the old questions about saving game state, but there are guides only for other languages/libraries not in C/Allegro.


texts:
In the official Unity Animator State Machine tutorial video animation clips are dragged out from the assets folder into the animator and dropped.

I have a 3D model that i bought online to experiment with that comes with animations. I added a custom made animation as well. These all work well in my demo project. But when i add a animator to the assets and try to drag and drop animations onto it it doesnt work. I get a forbidden-sign as a mouse pointer. I try to add animations through the inspector but that does not work either.

The tutorials makes it seem so easy and does not talk anything about what animations can be used. What am i doing wrong?


texts:
I am trying to have 2 animations on one GameObject, and I want them to play at the same time. I have been looking all over and messing around with the animator controller, but I cant get it working.

How do you play more than one animation at a time in Unity?


texts:
So, I'm not really sure where to start with this question. Feel free to tell me I'm stupid and Off Topic but I'd also like you to tell me why.

So, the maps in the game I am designing will consist of lots and lots and lots of voxels. Most of the voxels will just sit there and some of them will have methods run when they are touched or something happens around them. However, some blocks will constantly being doing something. Now, I'm not sure if I should have a array in every chunk (Group of voxels) that contains all the 'active' blocks or if there is another way. I know that some voxels will run code when they are loaded that makeup for all the time that they hadn't been doing anything but I may need to constantly run some voxels. (Machine that overheats or powers something can't just be loaded in 20 minutes after it blew up; or can it?)

So, now that that basic background is over, here is my question: Will an array storing all active entities in an area suffice as a way to run all the frame by frame methods of the blocks? Or is there a "normal" way to do this that I am unaware of?

EDIT: I just realized that the client that does rendering will not do a majority of the operations for the game engine. I will have a server that does it. The answer to this question is still largely relevant and helpful though. I just thought I'd mention my change.


texts: Some submeshes of my gameobject dissapear when I set the bindposes

texts:
Well, I'm trying to animate some Source models imported into Unity3D using this Unity-Source-Tools library:
https://github.com/lewa-j/Unity-Source-Tools
To animate a Mesh generated by this tool I need to create a SkinnedMeshRenderer replacing the MeshRenderer and the MeshFilter components, so I created this method:
    private static void ReplaceRenderer(this GameObject obj, SourceStudioModelv2 model)
    {
        if (obj.GetComponent<SkinnedMeshRenderer>() != null)
            return;

        var mesh = Object.Instantiate(obj.GetComponent<MeshFilter>().sharedMesh);

        const bool debugPoses = true;
        const bool useNativePoses = true;

        var nativeBuilder = debugPoses ? new StringBuilder($"Native Matrix\n{new string('=', 10)}\n") : null;
        var unityBuilder = debugPoses ? new StringBuilder($"Unity Matrix\n{new string('=', 10)}\n") : null;

        var nativeMatrix = model.GetBindPosesFromModel(nativeBuilder).ToArray();
        var unityMatrix = obj.transform.GetBindPoses(model.Bones, unityBuilder).ToArray();

        if (debugPoses)
        {
            Debug.Log(nativeBuilder.ToString());
            Debug.Log(unityBuilder.ToString());
        }

        var matrix = useNativePoses
            ? nativeMatrix
            : unityMatrix;

        mesh.bindposes = matrix;

        Object.Destroy(obj.GetComponent<MeshFilter>());
        Object.Destroy(obj.GetComponent<MeshRenderer>());

        var skinned = obj.AddComponent<SkinnedMeshRenderer>();

        skinned.sharedMesh = mesh;
        skinned.rootBone = obj.transform;
        skinned.bones = model.Bones;
    }

As you can see, I'm creating two bind poses, because one of them is created from this part of the code: https://github.com/lewa-j/Unity-Source-Tools/blob/c5469deb1d630c1582c940ff3cdb0f69fc55eda3/Assets/Code/Read/SourceStudioModel.cs#L724-L728
And this is how I create the bindposes:
Native Poses
    private static IEnumerable<Matrix4x4> GetBindPosesFromModel(this SourceStudioModelv2 model, StringBuilder sb = null)
    {
        for (var i = 0; i < model.MdlBones.Length; i++)
        {
            var mdlBone = model.MdlBones[i];
            // From: https://stackoverflow.com/a/49268287/3286975
            var matrix = (new Matrix4x4(
                new Vector4(mdlBone.PoseToBone[0], mdlBone.PoseToBone[1], mdlBone.PoseToBone[2],
                    mdlBone.PoseToBone[3]),
                new Vector4(mdlBone.PoseToBone[4], mdlBone.PoseToBone[5], mdlBone.PoseToBone[6],
                    mdlBone.PoseToBone[7]),
                new Vector4(mdlBone.PoseToBone[8], mdlBone.PoseToBone[9], mdlBone.PoseToBone[10],
                    mdlBone.PoseToBone[11]),
                new Vector4(0, 0, 0, 1)
            )).transpose;
            sb?.AppendLine($"{i}: {matrix.ToString("F2")}");
            yield return matrix;
        }
    }

Unity Poses
    private static IEnumerable<Matrix4x4> GetBindPoses(this Transform transform, Transform[] bones, StringBuilder sb = null)
    {
        for (var i = 0; i < bones.Length; i++)
        {
            var bone = bones[i];
            var matrix = bone.worldToLocalMatrix * transform.localToWorldMatrix;
            sb?.AppendLine($"{i}: {matrix.ToString("F2")}");
            yield return matrix;
        }
    }

And these are the values that each of them gives to me:
Unity Bindposes
https://pastebin.com/9tybGq7Z
And this is the result:

Native Bindposes
https://pastebin.com/YRZVq04y
But this one doesn't show anything.

I saw this reference on internet: https://hg.alliedmods.net/hl2sdks/hl2sdk/file/4966093d3274/utils/studiomdl/simplify.cpp#l3745
But I'm not sure if I'll be able to transcript this into Unity and if it will be useful...
If you would like to test this model out I created a *.unitypackage file for you to test:
https://mega.nz/file/xKpRSYwJ#j3ckM3GyFDFZKI6Y-OvN2cmcGC_GudGe2finLRQoA4U

So I don't know how to proceed in this case, could anybody help me out with this?


texts: Keep the timer counting after changing scenes

texts:
In my game you have 2 minutes to finish the whole game and after searching for an answer to my problem I think I should use DontDestroyOnLoad but I can't understand how to use it correctly. Here's the code:

public class countdownTimer : MonoBehaviour {

    public float myTimer = 120;
    public Text timerText;
    private bool timerIsActive = true;

    void Start () {
        timerText = GetComponent<Text> ();
    }

    void Update () {
        if (timerIsActive) {
            myTimer -= Time.deltaTime;
            timerText.text = myTimer.ToString ("f0");
            print (myTimer);

            if (myTimer <= 0) {
                myTimer = 0;
                timerIsActive = false;
                SceneManager.LoadScene ("lose");

            }
        }

    }
}


texts: Maths ? coordinates rotating around coordinates

texts: could you give me a tip please, a redirection to what is the "simple" math I need to learn and understand for the rotation of an object (its coordinate x, y) around an other object (an other x, y), I guess I could also describing my need as (x, y) moving coordinate orbiting around (x, y) fixed coordinates. It is for a little HTML5/Javascript game. Thank you.


texts: Any way to set drag events on a phaser 3 group?

texts:
I'm trying to set a drag event on a phaser 3 group, but I wasn't able to achieve what I want. I was reading some phaser 2 blogs, and they said that it isn't possible to set a group a drag event.
Can somebody help me with this? It's really impossible to set a drag event to a group?


texts: Where do I store strings? What's an efficient way of loading them?

texts:
I'm making a top-down RPG for iPhone. I'm using tilemaps (CCTMXTileMap) and the cocos2d-iphone engine.

I've made a class that can handle loading maps and NPCs onto the screen, a class that handles input, and, a class that is supposed to display dialog. The dialog class takes a single string, or an array, and displays it onscreen inside a neat dialog box, hiding the controls until the user taps on the screen, when it cycles to the next message, or if it's the last/only message, hides the dialog.

My NPCs are currently stored in Core Data. Their strings will need to be updated based on quest progress. Also, there are other bits of dialog, like signposts and other messages.

So, where do I put my game's textual content? I don't think Core Data is the right place, because of three reasons:

If my strings are stored in Core Data, I will probably have a harder time translating them.
If my strings are in Core Data, that only leaves me with strings for NPCs (which would be attached to the NPCs in Core Data). Where does that leave everything else?
If I leave my strings in Core Data, it's a bit heavy on the loading operations, no?

Given all of this background information, where do I put my strings and dialog in my game?

tl;dr

What's an efficient way to store strings for an iOS game so that they can be easily accessed, translated and referenced at various parts of the game?


texts:
Lets say I want to build iOS quiz with guessing images, and want to guess pokemons. If I edit image like :

is it violating copyrights?


texts: How to do game object perception at scale without some god object?

texts:
I've read through this post Interactions between game objects but it doesn't really address my question.

Background assumptions:

Maximum number of possible objects and the game still runs
Maximum sized game world and the game still runs
Game world is partitioned into sectors
Having an object/process at the game loop level to decide what objects are aware of what would be a bottleneck

The goal is feed an arbitrary game object the data it needs to do its thing.
The question is how should i go about doing this without some global god object/process that sits at the game loop level?

What I thought of (simplified):

Method 1 involved a list of all the objects. This would be the god object. Each game loop, determine an objects perception range, and pull the objects that fit.

Method 2 involved an event stream for each sector. A god process would look at the range of the object and put it into the sector's streams that are in range of the event. At each game loop, the god process would feed the object the streams of the sectors that are in its perception range.

Why I don't want a god object: How to avoid the GameManager god object?

Unfortunately, I'm not sure if the solutions outlined in that question really helps, as the "problem" recognized in that post is poor programming habits/design. At its core, the post and all the answers take for granted that the god object must exist. What I am after is to see if there's a way for objects in the world to be aware of each other without the all seeing eye.

In the real physical world, things do not commune with god, or gods, or the akashic record, or some other esoteric entity in order to be aware of and interact with each other. Things will do their thing and each thing relies on whatever method of sensing they were born with to do their thing.

It might be because of my limited imagination/knowledge/experience that I don't know how to replicate how the world works digitally or it might be because this is not possible. I don't know, hence this post.


texts: Unity IOS : Game crash in Facebook audience network while showing ad

texts:
I have integrated Facebook audience network for showing ads in my game.

I show Interstitial Ads.
Showing ads in ANDROID platform Successfully done but when i run my game on IOS it's getting crash while showing ads.

-My script for load and show Interstitial ads

using UnityEngine;
using AudienceNetwork;
using AudienceNetwork.Utility;

public class InterstitialAdScene : MonoBehaviour
{
    public static InterstitialAdScene instance;

    private InterstitialAd interstitialAd;
    private bool isLoaded;
    #pragma warning disable 0414
    private bool didClose;
    #pragma warning restore 0414

private void Awake()
{
    instance = this;

    AudienceNetworkAds.Initialize();

  //  AdSettings.AddTestDevice("38dab032-c36a-44e9-a7ed-f39eeef3093e");
    if (!isLoaded)
    {
        LoadInterstitial();
    }
}

// Load button
public void LoadInterstitial()
{
    Debug.Log("Loading interstitial ad...");

    // Create the interstitial unit with a placement ID (generate your own on the Facebook app settings).
    // Use different ID for each ad placement in your app.
#if UNITY_ANDROID
    interstitialAd = new InterstitialAd("917812518650022_917813945316546");
#endif

#if UNITY_IOS
    interstitialAd = new InterstitialAd("377269886512141_377270299845433");
#endif
    interstitialAd.Register(gameObject);

    // Set delegates to get notified on changes or when the user interacts with the ad.
    interstitialAd.InterstitialAdDidLoad = delegate ()
    {
        Debug.Log("Interstitial ad loaded.");
        isLoaded = true;
        didClose = false;
        string isAdValid = interstitialAd.IsValid() ? "valid" : "invalid";
    };
    interstitialAd.InterstitialAdDidFailWithError = delegate (string error)
    {
      //  Debug.Log("Interstitial ad failed to load with error: " + error);
    };
    interstitialAd.InterstitialAdWillLogImpression = delegate ()
    {
       // Debug.Log("Interstitial ad logged impression.");
    };
    interstitialAd.InterstitialAdDidClick = delegate ()
    {
       // Debug.Log("Interstitial ad clicked.");
    };
    interstitialAd.InterstitialAdDidClose = delegate ()
    {
       // Debug.Log("Interstitial ad did close.");
        didClose = true;
        if (interstitialAd != null)
        {
            interstitialAd.Dispose();
        }
    };

    // Initiate the request to load the ad.
    interstitialAd.LoadAd();
}

// Show button
public void ShowInterstitial()
{
    if (isLoaded)
    {
        interstitialAd.Show();
        isLoaded = false;
    }
    else
    {
        Debug.Log("Ad not loaded. Click load to request an ad.");
    }
}

void OnDestroy()
{
    // Dispose of interstitial ad when the scene is destroyed
    if (interstitialAd != null)
    {
        interstitialAd.Dispose();
    }
    Debug.Log("InterstitialAdTest was destroyed!");
}
}

-getting this crash while showing ad:

Terminating app due to uncaught exception 'FBFinalClassViolationException', reason: 'FBInterstitialAd is a final class and cannot be subclassed. FBInterstitialAd'

Please help me for this i don't know how to fixed it.

Thanks


texts: Box2D Bicycle Wheels Motor Problem - Flash 2.1a

texts:
I have made a bicycle with Box2D using several polygons for the frame at different angles connected using weld joints, and I have revolute joints on the wheels with a motor.

I have made some basic terrain (straight ground and a small ramp) and added keyboard input to control the bicycle with torque to balance it. All of this is done in with Box2D's Debug Draw.

When the bicycle is on its back wheel but diagonally forward (kinda like this position -> /) the motors just cause it go spinning backwards over when in reality it should either stay on its back wheel or go down onto both wheels.

Here's my code the revolute joints:

            //Front Wheel Joint

        var frontWheelJointDef:b2RevoluteJointDef = new b2RevoluteJointDef();
        frontWheelJointDef.Initialize(frontWheelBody, secondFrameBody, frontWheelBody.GetWorldCenter());
        frontWheelJointDef.enableMotor=true;
        frontWheelJointDef.maxMotorTorque=10000;
        frontWheelJoint = _world.CreateJoint(frontWheelJointDef) as b2RevoluteJoint;

        //Rear Wheel Joint

        var rearWheelJointDef:b2RevoluteJointDef = new b2RevoluteJointDef();
        rearWheelJointDef.Initialize(rearWheelBody, firstFrameBody, rearWheelBody.GetWorldCenter());
        rearWheelJointDef.enableMotor=true;
        rearWheelJointDef.maxMotorTorque=10000;
        rearWheelJoint = _world.CreateJoint(rearWheelJointDef) as b2RevoluteJoint;

And here's the relevant part of my update function:

            // up and down control wheels motor
        if (up) {
            motorSpeed-=0.5;
        }
        if (down) {
            motorSpeed += 0.5;
        }
        // left and right control cart torque
        if (left) {
            middleCentreFrameBody.ApplyTorque( -3);
            gearBody.ApplyTorque( -3);
            firstFrameBody.ApplyTorque( -3);
            secondFrameBody.ApplyTorque( -3);
            rearWheelToChainBody.ApplyTorque( -3);
            chainToFrontFrameBody.ApplyTorque( -3);
            topMiddleFrameBody.ApplyTorque( -3);
        }
        if (right) {
            middleCentreFrameBody.ApplyTorque( 3);
            gearBody.ApplyTorque( 3);
            firstFrameBody.ApplyTorque( 3);
            secondFrameBody.ApplyTorque( 3);
            rearWheelToChainBody.ApplyTorque( 3);
            chainToFrontFrameBody.ApplyTorque( 3);
            topMiddleFrameBody.ApplyTorque( 3);
        }
        // motor friction
        motorSpeed*=0.99;
        // motor max speed
        if (motorSpeed>100) {
            motorSpeed=100;
        }

        rearWheelJoint.SetMotorSpeed(motorSpeed);
        frontWheelJoint.SetMotorSpeed(motorSpeed);

Any ideas what might be causing this?

Thanks


texts: Using Smaller Textures in Unity on Older/Smaller devices

texts: In Unity, when you have MipMapping selected, will this cause the full size texture to always be brought into memory? I have a game which runs on high end mobile devices with ultra-high resolution textures, but I have complaints of it crashing on smaller/old devices. Will this fix it, or is there a more fitting way to address this problem?