texts: Accelerated movement in a specific time to a specific point

texts:
I am trying to move my sprite in a specific time to a specific position while using frame-independent or time-dependent movement. My sprite is also accelerated every frame to simulate gravity. I know the acceleration, the distance and the needed time. So i used the formula for acceleration based movement: s = 0,5 · a · t2 + v₀ · t + s₀ which is equivalent v₀ = (s-s₀) / t - a · t / 2. However, in my implementation the sprite does not move to the specified y-coordinate. The lower the starting y-coordinate is the higher is the resulting y-coordinate. For the time I used a quarter second. Here is my implementation:

    float resultY = viewport.getWorldHeight() / 6f * 5f;
    float time = 0.25f;
    velocity.y = (resultY - circle.getY()) / time - (-25f * time / 2f);

and these are called every frame:

    velocity.y -= 25f;
    circle.translate(velocity.x * delta, velocity.y * delta);`

What did I do wrong or is there a better method to move an accelerated sprite to a specific position in a specific time?

EDIT: I didn't mention that I want the sprite to stop at that specific point. I figured out that using my formula the sprite moves to the specified point in the specified time but it keeps moving and does not stop there. Is there a formula to solve that problem?

EDIT2: Ok, I realize that my last question is nonsense because stopping the sprite at a specified position and a specified time with a given acceleration is impossible. Thanks for all the answers.


texts: How do I move player with keyboard without applying forces? If I do playerBody.setLinearVelocity(new B2Vec2(0, 2)) it moves the player but when I release the key for movement, the ball is continuously moving for few seconds.


texts: Unable to enable IK on someone else's rig

texts:
I'm using someone else's character rig for reference but I'm not sure how I can enable IK solvers for the arms.  The hand controller has a NURBS control with an ikBlend attribute, but when I try to use the "Enable IK Solvers" tool, I get an error saying the attribute is locked or connected.

Clicking "Unlock Selected" on the attribute doesn't fix it.  Breaking the connections also breaks the ability for it to drive the enabled/disabled state of the IK handle.

The rigged character can be downloaded here if anyone wants to try to help me out: http://www.antcgi.com/2014/06/03/free-model-15-kila-lods-rig-dynamics/


texts: What kind of steering behaviour or logic can I use to get mobiles to surround another?

texts:
I'm using path finding in my game to lead a mob to another player (to pursue them). This works to get them overtop of the player, but I want them to stop slightly before their destination (so picking the penultimate node works fine).

However, when multiple mobs are pursuing the mobile they sometimes "stack on top of each other". What's the best way to avoid this? I don't want to treat the mobs as opaque and blocked (because they're not, you can walk through them) but I want the mobs to have some sense of structure.

Example:

Imagine that each snake guided itself to me and should surround "Setsuna". Notice how both snakes have chosen to prong me? This is not a strict requirement; even being slightly offset is okay. But they should "surround" Setsuna.


texts: UNITY Prevent 3D Text Render Trough All Object Without Shader

texts:
im tired of those answer i found trough search engine that just keep saying " the trick is to modify the shader " without thinking because they want to gain reputation , in my case , i have 2 3D text , one of them using special font and the other  one using default font , and the shader to prevent the text render trough all object from http://wiki.unity3d.com/index.php?title=3DText is not working and giving weird white square plus i don't want to change from default Arial font because i want to make them look different , i also cannot use sprite as background because i need to change their color trough script to give some effect , this is my picture showing my problem -- :

If the picture is not clear , go here https://i.stack.imgur.com/hLqC9.png

The menu dropped is at Z = 100 while the background is at Z = 20 , as you see , the text is rendered while the other not ( such as the border , ect ).

And this is the picture when my special font without using the shader

If the picture is not clear , go here https://i.stack.imgur.com/vbrQ1.png

Now the picture of my special font using the shader

If the picture is not clear , go here https://i.stack.imgur.com/hMAR2.png

Is there any possible way to prevent the text rendered without shader / change the background to sprite  ?

Im sorry if this already asked somewhere , i just cannot find it at search engine ( neither here ) .


texts: Do I have to ask for permission to use real company logos for advertising props in the world in my sports game?

texts: I'm making a simple turn-based Android ball flicking soccer game and I was thinking of creating a theme in a sports game, like soccer for example, usually had advertisement banner on walls and a bit realistic but cartoony. It is usually encountered in most sports-based game in any gaming platform. I have a question regarding this topic. Is it required to ask a permission to used some recognized ad banner designed walls (e.g. Adidas, Samsung, McDonalds, etc.) to be used as props for the game field like this one for example?


texts: Box2d set sprite to body that rotates around specific point

texts:
I want to rotate kinematic body around a specific point (I already done this part using

shape.setAsBox(1.8f / PPM, 0.2f / PPM, new Vector2(5.2f, 0), 0);

What I try is this:

PolygonShape shape = new PolygonShape();
shape.setAsBox(1.8f / PPM, 0.2f / PPM, new Vector2(5.2f, 0), 0); // !!!!

FixtureDef fdef = new FixtureDef();
fdef.shape = shape;
fdef.filter.categoryBits = categoryBits;
fdef.filter.maskBits = Constants.PLAYER;

bDef.position.set(((V_WIDTH / 32 - 3) / 2) / PPM, y / PPM);

body = world.createBody(bDef).createFixture(fdef).getBody();
body.setAngularVelocity(1f);
body.setUserData(new BodyUserData(categoryBits, colorArray[0]));

sprite.setOrigin(sprite.getWidth() / 2, sprite.getHeight() / 2);
sprite.setPosition(
    body.getPosition().x * 32 - sprite.getWidth() / 2,
    body.getPosition().y * 32 - sprite.getHeight() / 2
);

and here how I draw sprite

public void draw(SpriteBatch sb){
    sprite.setRotation(body.getAngle() * MathUtils.radiansToDegrees);
    sprite.draw(sb);
}

Unfortunately my sprite position is not the same as my body. It seems that sprite is rotating around it's center, not my point. Is it possible to fix that?


texts: How to improve my graphics on HTML5 canvas?

texts:
I am making my own army fighting simulator. Designer have made an 3D model with Blender and textured it, made animations. I have made sprites from that model and did programming. But the result is not as good as I expected. You can look at armyfight.com/simulator.html (refresh until it loads all images properly if it didn't at first time) and when you maximally maximize, you can see there are units moving. But I want to be them clearly visible, with details, high resolution like in flash-games and also that when they are really small units, would be understandable.

Is it possible on canvas?

Or it is my mistake and I must do somehow more HD sprites? I'm stuck now, and I don't know to improve the graphics..


texts:
I'm developing a top-down 2D game mostly based off a tilemap/grid. The player will be able to build structures on this grid while other objects like vehicles will move around freely. I've been working on the AI for awhile and have struggled with coming up with a searching method.

The basic behavior I'm looking for is that of a dog barking at someone inside a house. When the person inside runs to the left out of view, the dog will run left and could very well run around the whole house trying to reach/see the person.

Standard pathfinding algorithms look for shortest paths or near shortest paths. But the behavior I'm looking for is more dynamic and isn't about finding a path as much as searching for a way in.

The example I'm working with currently, as seen below, depicts a zombie that has sight of a player inside a building through a window. The player then moves to the right out of view. The desired effect would be that the zombie runs to the right and all the way around the building until finding the player again or giving up. Note that I don't want the zombie to go left and in through the door (which would be the shortest path) to reach the player.

I've fiddled with ideas about using steering behavior, weighted tiles based on distance, wall-following, etc. and nothing has really made sense yet. I'm looking for any thoughts on ways to go about this kind of behavior driven searching.


texts: Level Editor + Game -> Duplicating rendering/game specific code?

texts:
I've been reading about how to design code for a game. One thing I haven't been able to figure out is - how do you manage writing an outside-game level editor (not an 'in-game level editor') without 'copying' code from the game? For example, you might have to copy all code about the different types of entities you can have. You'll have to add the game rendering code.

My guess is this can be done by making a DLL out of the 'engine' part of the game. Then, share it between the actual game and the level editor.

Or is there a better/easier way to do this?


texts: Player Controller not working with rotation?

texts:
I have created a player character controller. It rotates first time good but not after rotate to its original position before rotation. I am sharing code with you so any one can help me, How can I rotate character controller to 60 on Z-axis and again back to 0 degree on Z-axis?

void Update()
{
    var inputDirection = inputDetector.DetectInputDirection();

    if (Input.GetKeyDown (KeyCode.Space)) {
        moveDirection.y = JumpSpeed;
        anim.SetBool ("RunToJump", true);
    } else {
        anim.SetBool ("RunToJump", false);
    }

    if (Input.GetKey (KeyCode.S) && controller.isGrounded) {
        anim.SetBool ("RunToSlip", true);
        controller.transform.Rotate (0, 0, 60);
        Invoke ("StopSlidding", 0.1f);
     }
  }
   void StopSlidding(){
   anim.setbool("RunToSlip", false);
   controller.transform.Rotate(0,0,0);
}

First controller.transform.Rotate(0,0,60); works fine but second time I invoke StopSlidding method controller.transform.Rotate(0,0,60); It doesn't work. So my player character controller remains same on Z-axis 60 degree. I want to rotate it again to Z-axis 0 degree. So Any one can help me on this problem? My player starts moving with game scene start so there are no matter about moving player.
I am using Controller.Move(); to move my player.


texts: The script in the event trigger disappears when the player dies

texts:
I am making an 2D platformer for mobile in unity with c#. Right now it is setup in a way that I have one joystick that controls the players shooting, arm rotation and movement. But on that joystick there is an event trigger which is what I use to make the player shoot the gun when the joystick is pressed. The problem I am having is when the player dies the script in the event trigger disappears and I am no longer able to shoot. I am calling Destory() when the player dies and he does have lives. the location of that script is on the player I am not sure if that has anything to do with it but of anybody has any suggestions that would be great.

Here is the code for when the player dies and respawns

public static void KillPlayer (Player player)
{
    Destroy (player.gameObject);
    _remaningLives -= 1;
    if (_remaningLives <= 0)
    {

        gm.EndGame();

    }else
    {
        gm.StartCoroutine(gm._RespawnPlayer());
    }
}


texts: How do I draw a full screen quad in DirectX 11?

texts: How do I draw a full screen quad that shows red on the screen?


texts: Using a rule engine for a text-based web game

texts:
I have a database table that stores basic player data for the game.

It looks like this:

_________________________________________________________
player_id | player_level | player_class_ref | player_exp
    P1            8              W1            68349518
_________________________________________________________
level | required_exp
  1         100
 ...
  8         80000000
____________________

The game itself is text and browser based.

I decided to use a rule engine to adjust player data when needed.

It executes after every player event - for example, killing a monster or finishing a quest.

The sample rule looks like this

when
    player_exp > closest_level_exp
then
    player_level + 1
    player_exp = abs (closest_level_exp - player_exp)

There might be a lot of similar rules - for example, quest accepting.

So my question is - Is my approach viable for a web and text based game?

I am not sure how such things are usually implemented in games, such rules be hard coded, or they are stored another way?


texts: How to smoothly let an object move along a curved line

texts:
I'm wondering how to move objects, with rotation taken into account, to follow a curved line

see: http://www.youtube.com/watch?v=iPpO24FeAX4 for an example

In particular I wonder:

how to store the points, how many
points to store for a smooth line
like that
how to interpolate the
curves
how to interpolate between
the object and the first "waypoint"
along the line


texts: Unity: Retrieve animation names from imported blend file

texts:
I am just trying to generate a list from all animations within my Blender Asset file (see image)

This is what I have so far:

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

public class DropDown : MonoBehaviour {

    public GameObject character;
    public Dropdown dropdown;

    // Use this for initialization
    void Start () {
        PopulateList();
    }

    void PopulateList(){
        // TODO: Read values from character
        List<string> names = new List<string>() { "idle", "cheering" , "jump" };
        dropdown.AddOptions(names);
    }
}

The character is the actual blender asset (base_character_29).
The List names needs to be replaced with an array of my animations so I can populate a dropdown.
I am using a humanoid rig so I am only having an "Animator" Component on my GameObject.

I appreciate any kind of help,
thanks in advance!


texts:
I am currently building a little game in XNA and found something strange. I want to draw many blocks next to another (1x1x1 with a texture on the side)

So what happens when I do it this lines appear:

When I move the camera the lines change the position or disappear completely. I know this is because the side of the blocks are drawn but i do not know why. Does anybody of you know a solution for my problem? (removing the sides of the cube does not count)


texts:
I want to use crittercism with my Unity project. In Unity I am developing a game for iOS and Android platform. I did enough Google searching to come to the conclusion that Unity doesn't support this by itself and there aren't much tools out there to help me.

Can someone suggest a way to do it?

If not, is it possible for me to get access to the editor logs of Unity programmatically so that I can send these logs to my server directly. (I'll however still need to know when a crash occurs.)

I was thinking of a "hack". Please tell me if it is doable. On building the project, Unity creates an xcode project for iOS. I was thinking of opening the xcode project itself and putting the relevant commands to send the logs to crittercism, in case a crash occurs. However I am not able to think of a way to do this with Android.


texts: Breakout... Getting the ball reflection X angle when htitting paddle / bricks

texts:
Im currently creating a breakout clone for my first ever C# / XNA game. Currently Ive had little trouble creating the paddle object, ball object, and all the bricks. The issue im currently having is getting the ball to bounce off of the paddle and bricks correctly based off of where the ball touches the object. This is my forumala thus far:

if (paddleLocation.Intersects(ballLocation))
{
    position.Y = paddleLocation.Y - texture.Height;
    motion.Y *= -1;

    // determine X
    motion.X = 1 - 2 * (ballLocation.X - paddleLocation.X) / (paddleLocation.Width / 2);
}

The problem is, the ball goes the opposite direction then its supposed to. When the ball hits the left side of the paddle, instead of bouncing back to the left, it bounces right, and vise versa. Does anyone know what the math equation is to fix this?


texts: Children of canvas objects do not register OnMouseUpAsButton

texts:
Objects I create inside my canvas do not register the OnMouseUpAsButton() event. I tried doing it on an empty project and it doesn't work so I guess I'm misunderstanding how something works. That being said, objects inside game world register event properly. I tried reading documentation but I still don't get why this is happening.

My code (the only code used in the project)

using UnityEngine;
using System.Collections;

public class test_click : MonoBehaviour {

void OnMouseUpAsButton()
{
    Debug.Log("Mouse up test click");
}

public void Thisworks()
{
    Debug.Log("yes");
}

void Start () {}
void Update () {}
}

My project objects:

I have spent the last 12 work hours searching for causes of this problem so I'm sure it is something absolutely obvious yet I just can't see it.


texts: Game Maker Studio 2 problems with too many instances

texts:
So I am trying to make a management game, a space station simulator if you will, with potentially hundreds and thousands of customers entering and leaving the station every game day. So my plan of handling this is to first create a persistent object called oManager. Over the course of the game, oManager will continuously spawn instances of this object called oPerson.

The part of oManager that spawns person:

global.dailyflow = 100;
show_debug_overlay(true);
var number_a_day = irandom_range(ceil(global.dailyflow*0.6),global.dailyflow);
trader_base = floor(number_a_day*0.02);
trader_extra = floor(trader_base*(1+global.trader_modifier/100));
tourist_base = ceil(number_a_day*0.1);
tourist_extra = ceil(tourist_base*(1+global.tourist_modifier/100));
passerby_base = ceil(number_a_day*0.53);
passerby_extra = ceil(passerby_base*(1+global.passerby_modifier/100));
shopper_base = ceil(number_a_day*0.25);
shopper_extra = ceil(shopper_base*(1+global.shopper_modifier/100));
mercenary_base = floor(number_a_day*0.1);
mercenary_extra = floor(mercenary_base*(1+global.mercenary_modifier/100));

repeat(trader_base+trader_extra){
    with instance_create_layer(0,0,"instances",oPerson){
        guy_type = 0;
        event_user(0);
    }
}

repeat(tourist_base+tourist_extra){
    with instance_create_layer(0,0,"instances",oPerson){
        guy_type = 1;
        event_user(0);
    }
}

repeat(passerby_base+passerby_extra){
    with instance_create_layer(0,0,"instances",oPerson){
        guy_type = 2;
        event_user(0);
    }
}

repeat(shopper_base+shopper_extra){
    with instance_create_layer(0,0,"instances",oPerson){
        guy_type = 3;
        event_user(0);
    }
}

repeat(mercenary_base+mercenary_extra){
    with instance_create_layer(0,0,"instances",oPerson){
        guy_type = 4;
        event_user(0);
    }
}

Each oPerson instance decides on how many days he stays, where he would go to and how much money he spends each day, with much more to come in the future. However, the problem I am currently facing is that the game would just crash after about one game day. I think the problem is there are just too many instances and the game just cannot handle it. I tried to create only one oPerson of each type per day and it worked fine. I consider it essential to make each person an instance itself, considering they have to make pretty complex decisions, but I don't know how to make it work.

The game crashes specifically when I click on a button to change room. All of the objects are persistent.


texts:
We're looking at developing a 2D game that could target Xbox 360.  Ideally, we'd also like to submit the game via the XNA program so that gamers could try out the game over Xbox Live.  We really love the fact that SDL is cross-platform.

Is writing a 2D game in SDL and then also targeting Xbox 360 possible, and if so how difficult might it be?


texts: How do I get the player to collide with another object to use as a boundary?

texts:
I'm trying to make a simple game where you move a sphere from left/right and try to avoid falling cubes. If a cube touches the player (sphere), the player dies. I'm trying to set up boundaries using a cylinder with a collider, but every time I hit the collider boundary, the player disappears like they would if they hit a cube. Here is my player script:

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

public class Move : MonoBehaviour
{
public float moveSpeed = 1;

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

}

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

    transform.position += new Vector3(Input.GetAxis("Horizontal") * moveSpeed, 0, 0);
}

void OnCollisionEnter(Collision collision)
{
    if (collision.gameObject.tag == "Cube")
    {
        Destroy(collision.gameObject);
        Destroy(gameObject);
    }
}

}


texts: Seamless tilemap rendering (borderless adjacent images)

texts:
I have a 2D game engine that draws tilemaps by drawing tiles from a tileset image. Because by default OpenGL can only wrap the entire texture (GL_REPEAT), and not just part of it, each tile is split off in to a separate texture. Then regions of the same tile are rendered adjacent to each other. Here's what it looks like when it's working as intended:

However as soon as you introduce fractional scaling, seams appear:

Why does this happen? I thought it was due to linear filtering blending the borders of the quads, but it still happens with point filtering. The only solution I've found so far is to ensure all positioning and scaling only happens at integer values, and use point filtering. This can degrade the visual quality of the game (particularly that sub-pixel positioning no longer works so motion is not so smooth).

Things I have tried/considered:

antialiasing reduces, but does not entirely eliminate, the seams
turning off mipmapping, has no effect
render each tile individually and extrude the edges by 1px - but this is a de-optimisation, since it can no longer render regions of tiles in one go, and creates other artefacts along the edges of areas of transparency
add a 1px border around source images and repeat the last pixels - but then they are no longer power-of-two, causing compatibility problems with systems without NPOT support
writing a custom shader to handle tiled images - but then what would you do differently? GL_REPEAT should be grabbing the pixel from the opposite side of the image at the borders, and not pick transparency.
the geometry is exactly adjacent, there are no floating point rounding errors.
if the fragment shader is hard coded to return the same color, the seams disappear.
if the textures are set to GL_CLAMP instead of GL_REPEAT, the seams disappear (although the rendering is wrong).
if the textures are set to GL_MIRRORED_REPEAT, the seams disappear (although the rendering is wrong again).
if I make the background red, the seams are still white. This suggests it's sampling opaque white from somewhere rather than transparency.

So the seams appear only when GL_REPEAT is set. For some reason in this mode only, at the edges of the geometry there is some bleed/leakage/transparency. How can that be? The entire texture is opaque.


texts: I would like to know if there is any copyright related rules to name a game studio specially for android appstore. I searched at the U.S. Copyright Office website and found many matches for same names. None of them are game studios though. Is it legal to choose one of those names if none of them are game studios? Also, what are the rules I need to know for starting a new indi game studio?


texts: Generating color for mesh in Texture3D or shader?

texts:
In Unity, I'm trying to choose between two ways of procedurally colorizing meshes (with vertex color). The main concern here is performance, knowing that my software is already GPU bound (more specifically on the memory bandwidth side)

First option: Generate the color in the fragment shader. The advantage here is that there is no memory transfert needed. The disadvantages are that the procedural generation of a color implies a pretty complex "algorithm" with branching(ifs) and noise and I'm worried that doing this calculation for every pixel is going to be really slow.
Second option: Generate all the colors in C#, store them in a 3DTexture and read it in the shader to assign color to each pixel. The disadvantage here is that if the texture is sent to the GPU every frame, that will obviously not help with my memory bandwidth problem... It depends on a thing that I'm not sure about, is the texture stored in the GPU (if I dont change it of course), or does Unity sends it back at every frame, or for each GameObjects?

Which one would you choose?
Do you see some other thing I should take into account?


texts: 3D Studio MAX dxf model to OpenGL and DirectX

texts:
Main Question

I saw this Loading and Animating MD5 Models with OpenGL an old post explaining .md5mesh .md5anim files. Is there any similar alternate mechanisms?

Additional Questions

1.) Is there an open source tool or a Plug in for 3ds max to convert a .DXF file to such files which can be used in 3D OpenGL+DirectX game programming.

2.) If I am developing a game in this approach how to make these model files encrypted and make big single file which contains all this file, so that the user cannot crack/hack it?

3.) If I am providing an update via an online gaming server, then how to I update this models and keep it encrypted again?


texts: Creating a curve path for gameObject which reacts to Triggers

texts:
I am trying to create a path for a gameObject which will bounce off other gameObjects if it hits them. Can I get an idea on how I could possibly get this curve path set up.

Stuck on ideas. I don't want to use ITween and I can't simply define the entire path via ITween either. I need to account for whether it hit another gameObject and cause it to carry on the path or just fall through.

Attached the image below for clarification. I need the circle(purple) gameObject to bounce along the white path provided the rectangle(green) gameObject is in place to cause a Trigger and let the path carry on or the circle gameObject just simply falls through.

There is only 1 green gameObject at any point of time which moves to one of the 3 possible positions. Placed 2 just for clarification.


texts: How to express and verify euler rotation limits in Unity

texts:
I need to find a way to set min and max angles for each Euler component and check whether transform.localEulerAngles falls within those limits.

My current code looks like this:

class JointLimit : MonoBehaviour
{
    [SerializeField]
    [Range(-180f, 180f)]
    private float minX = -180f;
    [SerializeField]
    [Range(-180f, 180f)]
    private float maxX = 180f;
    [SerializeField]
    [Range(-180f, 180f)]
    private float minY = -180f;
    [SerializeField]
    [Range(-180f, 180f)]
    private float maxY = 180f;
    [SerializeField]
    [Range(-180f, 180f)]
    private float minZ = -180f;
    [SerializeField]
    [Range(-180f, 180f)]
    private float maxZ = 180f;

    public float Error
    {
        get
        {
            Vector3 localEuler = transform.localEulerAngles;
            Vector3 signedLocalEuler = new Vector3(Mathf.DeltaAngle(localEuler.x, 0), Mathf.DeltaAngle(localEuler.y, 0), Mathf.DeltaAngle(localEuler.z, 0));

            float error = 0;
            error += Mathf.Max(0, minX - signedLocalEuler.x);
            error += Mathf.Max(0, signedLocalEuler.x - maxX);
            error += Mathf.Max(0, minY - signedLocalEuler.y);
            error += Mathf.Max(0, signedLocalEuler.y - maxY);
            error += Mathf.Max(0, minZ - signedLocalEuler.z);
            error += Mathf.Max(0, signedLocalEuler.z - maxZ);
            return error;
        }
    }
}

This basically checks whether the Euler components fall within the specified range and sums the exceeding angles up to an error.

The problem is that Unity internally stores rotations as Quaternions and that there can be several euler representations for a single Quaternion, like Euler 123f, 17f, 235f and Euler 57f, 197f, 55f are the same thing.

Is there any way I can bring an Euler representation into some kind of normalized form that allows me to reliably check it against my limits?


texts: Should Unity lifecycle methods be annotated with the UsedImplicitly attribute?

texts:
Does annotating Unity lifecycle methods with the UsedImplicitly attribute improve the readability of your code?

For example:

public class Example : MonoBehaviour
{
    [UsedImplicitly]
    private void Awake()
    {
        DoSomething();
    }

    private void DoSomething()
    {
        // ...
    }
}

This blog post on "Structuring Your Unity MonoBehaviours" suggests this approach as a useful convention.

  Annotate any Unity lifecycle methods (Start, Awake, Update, OnDestroy
  etc.), event methods, and other functions that are implicitly (or
  automatically) invoked in your code with the [UsedImplicitly]
  attribute. This attribute, although included in the UnityEngine.dll,
  is used by ReSharper to disable code cleanup suggestions for methods
  that are seemingly unreferenced. It also helps to make the code easier
  to read for people who are newer to Unity and your codebase,
  especially for events that are referenced via the inspector.

(Note: I don't think ReSharper shows code-cleanup suggestions for seemingly unreferenced Unity lifecycle methods, so that might be outdated advice.)

I agree with the above post that it could be helpful for those newer to Unity. I also think it could be useful to label those Unity lifecycle functions that are not used as frequently as Awake, Start, and Update. But I am wondering if this is actually a good convention for "clean code", or if it's just noise that reduces readability.


texts:
Anyone knows any implementation of the "light at the end of tunnel" effect? where the outside is entirely bright and gradually becomes more visible?

The reverse could also be true, where the inside of the tunnel is very dark until you step in and gradually start seeing

Any implementation/algo will help or even the actual name of the effect

Thanks


texts: Help setting up money system in game maker

texts:
I am trying to make a clicker game where one button makes the item and then one button sells the item. My problem is that I don't know how to make the one button stop selling when it reaches 0 items to sell. My code for the selling of the item as of right now looks like this in game maker:

///Sell items
global.money+=global.PC
global.items-=global.PC

It works to subtract per click, but once it reaches 0, it keeps going in to negatives. I am very new to this so forgive my asking probably simple questions.


texts:
I am programmatically generating terrain using unity's terrain object and assigning height maps to it via the terrainData, the problem is that there are seams even when using the GroupingId(which is used for auto connect).
I even tried creating a terrain object in the editor with neighbours, and modified their terrain data via script, seams still there.

I have also tried SetConnectivityDirty after applying terrainData.

Most people who have reported this seemed(lol) to have issues with their normals at the edges, I cant see that being the issue here, but if it is, how do i approach solving it given I am using unity terrains.

If there is no good answer I will have to resort to custom meshes and lose all the nice terrain tool functionality.

Edit: Here is how I'm setting heights.

var terrain = GameObject.Find("test").GetComponent<Terrain>();
var terrainData = terrain.terrainData;
var noiseMap = Tool_Generators.GenerateNoiseMap(chunkSize, seed, scale, octaves, persistance, lacunarity, 0f, 0f);
terrainData.SetHeights(0, 0, noiseMap);

Then the actual noise generation is just a 2D array of heights, i have been using a simplified version with only 1 pass for testing.

  public static float[,] GenerateNoiseMap(int chunkSize, int seed, float scale, int octaves, float persistance, float lacunarity, float offsetX, float offsetY)
  {
    float[,] noiseMap = new float[chunkSize, chunkSize];

    for (int y = 0; y < chunkSize; y++)
    {
        for (int x = 0; x < chunkSize; x++)
        {
            float noiseHeight = 0;

            float sampleX = (x + offsetX) / scale;
            float sampleY = (y + offsetY) / scale;

            noiseHeight = Mathf.PerlinNoise(sampleX, sampleY);
            noiseMap[y, x] = noiseHeight;
        }
    }

    return noiseMap;
  }


texts: Civilization 4: time in own scenario runs up too quickly

texts:
In Civilization 4 (Beyond the Sword) I started making a scenario that focuses on the colonization of North America. For added realism, I set the StartYear=1780.
Everytime I run the scenario, the time runs up far too quickly–probably because I set Era=ERA_ANCIENT and GameTurn=0–so that after just twenty turns the clock nears present day.

I'm not really sure how to go fix this, other than by playing an actual marathon game from the start up to the year 1780 and copy over the values.

Is there any way to calculate/know the right values for my scenario?


texts:
I am trying to implement sprite animation using coco2dx. I have tried several demos, but all of them are same. While I tried, getting violation error in my code.

CCSpriteFrameCache::sharedSpriteFrameCache()->addSpriteFramesWithFile("AnimBear.plist");
    CCSpriteBatchNode *spreetsheet = CCSpriteBatchNode::create("AnimBear.png");
    this->addChild(spreetsheet);

CCArray *bearArray = new CCArray();
     for(int i = 1; i <= 8; i++)
{
        char name[32] = {0};
         sprintf(name, "bear%d.png",i);
        bearArray->addObject(CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName(name));
}
    CCAnimation *walkAnim = CCAnimation::animationWithSpriteFrames(bearArray, 0.1f);
    CCSize size = CCDirector::sharedDirector()->getWinSize();
    CCSprite *bear = CCSprite::spriteWithSpriteFrameName("bear1.png");
    bear->setPosition(ccp(size.width/2, size.height/2));
    CCAction *walkAction = CCRepeatForever::actionWithAction(CCAnimate::actionWithAnimation(walkAnim));
    bear->runAction(walkAction);
spreetsheet->addChild(bear);

Error is coming in first line while we passing plist refrence. I am using Visual Basic 2010 and put both files in Resource folder (png and plist).


texts: Is it possible to change the position of a Farseer joint tie point?

texts:
When I create a revolute joint in Farseer, then there is always a tie point in the center of each of the two bodies. Is it possible to change the position of a tie point?

For example:

I created a revolute joint but I want to change the tie point of the Windmillsail1 body. Is it possible to change the position of the point to the lower edge of the Windmillsail1 body? I marked the position of the lower edge with a red arrow.

My code:

Body Windmillsail1, Windmillball;
RevoluteJoint RevJointA,
List<Vertices> list = new List<Vertices>();
Vector2 _origin;
float _scale;

uint[] data = new uint[WindmillsailSprite.Width * WindmillsailSprite.Height];
WindmillsailSprite.GetData(data);
Vertices textureVertices = PolygonTools.CreatePolygon(data, WindmillsailSprite.Width, false);
Vector2 centroid = -textureVertices.GetCentroid();
textureVertices.Translate(ref centroid);
_origin = -centroid;
textureVertices = SimplifyTools.ReduceByDistance(textureVertices, 4f);
list = Triangulate.ConvexPartition(textureVertices, TriangulationAlgorithm.Bayazit);
_scale = 1f;
Vector2 vertScale = new Vector2(ConvertUnits.ToSimUnits(1)) * _scale;
foreach (Vertices vertices in list)
{
  vertices.Scale(ref vertScale);
}

Windmillsail1 = BodyFactory.CreateCompoundPolygon(world, list, 1.0f, BodyType.Dynamic);
Windmillsail1.BodyType = BodyType.Dynamic;
Windmillsail1.Mass = 10;
Windmillsail1.IsSensor = true;
Windmillsail1.Position = new Vector2(1.45f, 4.05f);
Windmillsail1.Rotation = MathHelper.ToRadians(0);
Windmillsail1.CollisionCategories = Category.Cat10;

Windmillball = BodyFactory.CreateCircle(world, 0.25f, 1.0f);
Windmillball.BodyType = BodyType.Static;
Windmillball.Position = new Vector2(1.63f, 4.64f);

RevJointA = JointFactory.CreateRevoluteJoint(world, Windmillsail1, Windmillball, new Vector2(0f, 0f));
RevJointA.MotorSpeed = MathHelper.PiOver4;
RevJointA.MotorImpulse = 100;
RevJointA.MotorEnabled = true;
RevJointA.MaxMotorTorque = 100;

spriteBatch.Draw(WindmillsailSprite, ConvertUnits.ToDisplayUnits(this.Windmillsail1.Position), null, Color.White, this.Windmillsail1.Rotation, _origin, 1.0f, SpriteEffects.None, 0f);


texts: Pushing an object left and right (gravitation towards center of a circle)

texts:
So this is the problem:

I have an object pulled towards the center of a circle and I am unable to figure out how to move the object left and right depending on its rotation around the circle.

I basically need to know in which "angle" to push the object if the left or right key was pressed.

Thank you


texts:
I created an empty iOS project and then added a custom GLView class which is then added to AppDelegate. I have following questions:

1) How do I enable hi-res retina mode on iPhone 4? Currently I am using the following code to check for device. The following code is from the AppDelegate where it first allocates GLView and then sets contentScale.

CGRect screenBounds = [[UIScreen mainScreen] bounds];
self.window = [[[UIWindow alloc] initWithFrame:screenBounds] autorelease];
// Override point for customization after application launch.
_view = [[GLView alloc] initWithFrame:screenBounds];
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
    NSLog(@"iPad detected");
}
else {
    if ([[UIScreen mainScreen] respondsToSelector:@selector(scale)] && [[UIScreen mainScreen] scale] == 2) {
        NSLog(@"iPhone4 detected");
        _view.contentScaleFactor = [[UIScreen mainScreen] scale];
    }
    else {
        NSLog(@"iPhone detected");
    }
}

self.window.backgroundColor = [UIColor whiteColor];
//self.window.rootViewController = [[[UIViewController alloc] initWithNibName:nil bundle:nil] autorelease];
[self.window addSubview:_view];

But even after setting content factor it is drawing pretty poor quality polygons with jagged edges as shown in the image below:

http://farm8.staticflickr.com/7358/8725549609_e2ed1e0e2a_b.jpg

Is there any way to set the resolution to 960x640 instead of the default 480x320 ?

Please note that I can not use "someImage@2x.png" because I am generating images at runtime in the render buffer.

2) Second problem I am having is this warning message:

"Application windows are expected to have a root view controller at the end of application launch"

Thank you for your time.

Edit:
Problem solved. Set contentScale before allocating render buffer memory, i.e: inside GLView, not AppDelegate.


texts: Problem while creating balancing board using Unity physics

texts:
I am trying to create a balancing board using Unity Physics. Below are the steps that I followed to achieve my result and I got unexpected Unity Physics.

Balancing-bar and base are connected through a sphere and sphere is having a fixed joint with balancing-bar and I freeze y,z rotation and all the positions of the sphere and base's all position and rotation are fixed.
Balancing-bar is having a rigid body with Mass, Drag and Angular Drag 5,1,5 respectively and rotation on y and z are Freeze. Balancing bar is connected to the sphere using Hinge Joint. below I attached an Image for understanding.

I created a video for understanding.

Video Link

Problems:
 1. When I throw an object a bit above from my balancing-board then it that side of bar automatically pulls down.

 (Both objects is having the same mass=1 and both are 4 Meter far from the pivot point and on "Let's check" button I just turn off board's isKinematic)

When I do the same before Unlocking the isKinematic it works perfectly well.

I am just blank here what to do next or where I did the mistake, any help is appreciated.


texts: box2dlights confuses ScreenUtils for screenshots in libGDX

texts:
I take screenshots as usual in libGDX via ScreenUtils.getFrameBufferPixmap(), which works fine. Hoever, when I call RayHandler.updateAndRender() during rendering, then the screenshot only contains those assets rendered after this call. All other pixels in the screenshot are transparent.

What is the best way to deal with this issue?


texts:
I've been reading Timothy Wright's "Fundamental 2D Game Programming With Java". I'm trying to apply its principles to a Lunar Lander game - it's a JSFiddle for now, and can be found here.

The problem is with the collision function. It never returns true. I don't actually understand how it works, I just ported it from Java to JavaScript. It would be nice if someone could enlighten me. (I'm bad at math...)

The ship is just a 14x14 rectangle (with an antenna on top :) ). It is translated with a translation matrix according to the changing velocity.

function collision() {
  for(var i = 1; i < map.length; i++) {
    var largestMin = -Number.MAX_VALUE;
    var smallestMax = Number.MAX_VALUE;
    var start = new VectorPoint((i - 1) * 20, map[i-1]);
    var end = new VectorPoint(i * 20, map[i]);
    var d = VectorFunctions.sub(end, start);
    var len = VectorFunctions.len(d);
    d = VectorFunctions.norm(d);
    for(var j = 0; j < 2; j++) {
      var n = VectorFunctions.sub(shipCopy.body[j], shipCopy.body[j + 1]);
      n = VectorFunctions.norm(n);
      var sub1 = VectorFunctions.sub(shipCopy.body[j], start);
      var sub2 = VectorFunctions.sub(shipCopy.body[j+1], start);
      var e0 = VectorFunctions.dot(n, sub1);
      var e1 = VectorFunctions.dot(n, sub2);
      var f = VectorFunctions.dot(n, d);
      if(Math.abs(f) > EPSILON) {
        var t0 = e0 / f;
        var t1 = e1 / f;
        if(t0 > t1) {
          var swap = t0;
          t0 = t1;
          t1 = swap;
        }
        largestMin = Math.max(largestMin, t0);
        smallestMax = Math.min(smallestMax, t1);
        console.log(largestMin + ", " + smallestMax);
        if(largestMin > smallestMax) {
          return false;
        }
        if(smallestMax < 0) {
          return false;
        }
      }
      else if(e0 * e1 > 0) {
        return false;
      }
    }
  }
  var t = t0 > 0 ? t0 : t1;
  return true;
}

The VectorFunctions namespace is defined as follows:

var VectorFunctions = {
  // v1: VectorPoint
  // v2: VectorPoint
  add: function(v1, v2) {
    return new VectorPoint(v1.x + v2.x, v1.y + v2.y);
  },
  // v1: VectorPoint
  // v2: VectorPoint
  sub: function(v1, v2) {
    return new VectorPoint(v1.x - v2.x, v1.y - v2.y);
  },
  // v: VectorPoint
  // n: number
  div: function(v, n) {
    return new VectorPoint(v.x * n, v.y * n);
  },
  // v: VectorPoint
  len: function(v) {
    return Math.sqrt(v.x * v.x + v.y * v.y);
  },
  // v: VectorPoint
  norm: function(v) {
    return VectorFunctions.div(v, VectorFunctions.len(v));
  },
  // v1: VectorPoint
  // v2: VectorPoint
  dot: function(v1, v2) {
    return v1.x * v2.x + v1.y * v2.y;
  },
  // x: number, y: number, w: number
  vectorW: function(x, y, w) {
    var v = new VectorPoint(x, y);
    v.w = w;
    return v;
  }
};

The VectorPoint class is here...

// x: number
// y: number
function VectorPoint(x, y) {
  this.x = x;
  this.y = y;
  this.w = 1;
};


texts: Avoiding Incredibuild error when building

texts:
Apparently the UE4 Installed Build script function is trying to use Incredibuild, but halting with an error.

I believe this is due to my Agent Services not running, due to the fact that I have none.

I don't have a license, and so I can't use Incredibuild.

How can I modify the scripts to not use Incredibuild?
I downloaded FastBuild, and want to give that a try.
I just need help in knowing which scripts to modify.


texts: How do we coordinate which order the systems get processed within an ECS?

texts:
If I knew all of the systems at compile time, I could order them myself. However, I intend on having user-defined mods. This adds a level of complexity, in that I (as the framework developer) don't know which mods will be developed, or installed on a particular user's machine.

I've thought about adding some sort of execution ordering

// within core code
systemRegistrar.register(PhysicsSystem.class).before(RenderingSystem.class);

// within third-party mod
systemRegistrar.register(ModSystem.class).before(PhysicsSystem.class);

I've thought about an incidental ordering using some sort of message or event bus

// within core code
// - PhysicsSystem
public void update() {
    // do physics-y stuff
    eventBus.send(new PhysicsSystemUpdatedEvent());
}

// - RenderingSystem
public void handle(PhysicsSystemUpdatedEvent event) {
    // do rendering stuff
    eventBus.send(new RenderingSystemUpdatedEvent());
}

But this blurs the line between what will happen, and what could happen.

Another thought that came into my mind is that we can be a little bit dirty and not care too terribly much about what order the systems get executed in, because even if we render before the physics are applied, the next frame will then render the physics update that was made in the previous frame. It's consistent, but it blurs the line between what happens within a frame.


texts:
If one were to code a game for most versions of Windows, which API should be used?

I know DirectDraw works from NT4 and up (although DirectDraw is emulated on NT4 with GDI). However, I am told DirectDraw is deprecated in newer versions of Windows?

I could revert to just GDI, but then it is hard to completely eliminate flicker, since there is no double buffering with flipping between buffers.

Should I go for Direct3D or DirectDraw? Or is there some way of completely eliminating flicker in GDI or some other Windows API I am not aware of?

If Direct3D is the answer, which version of it is supported on most platforms?


texts:
I need to overlay an image on the screen, the whole screen.
The process would be like:
A screenshot is captured by the camera. It's blended with another image and the resultant image is displayed on the screen. However, this overlaid image should not be seen by the camera.
How would I go about doing this in the Unreal Engine?


texts:
Edit: To sum up my question, what is the established back gesture for iOS games (when no pause button exists)?

I have a block puzzle game, square grid, and some levels fill up the whole screen with them. In Android this is no problem because there's a hardware back button. iOS devices, however, have no such thing.

I need some kind of back button to get to the menu, where you can restart, undo, select other levels, go to options page, etc.

I looked at iOS game demos on youtube. All I found was many of them have a pause button in some corner, but this is not a great solution in my case. I could not find a demo illustrating some kind of back gesture, like swiping from the left edge towards the right? Most demos are direct screen captures instead of showing a user and their hands, so I could not confirm this.

I figure most iOS games have adopted some kind of standard practice for this. What is it?

EDIT: I found this article about iOS 7 doing a left-right swipe to go back one page, apparently for safari. This was kinda my first though, because surely there is a back gesture for the back button of web pages? I don't know if this same gesture is standard practice in iOS games, but I put it here because it's my first guess.


texts:
I have integrated WebSocketSharp with Unity 2018.4.14f1 and it works well with Android and IOS. I wanted to know that most of the other socket.io plugins for unity have a wrapper of Class Packet over the top which binds and sends packetID, EventType along with Data.

My question is, do we need to write such a wrapper for WebSocketSharp also in Unity?


texts: Smooth drag scrolling of an Isometric map - Html5

texts:
I have implemented a basic Isometric tile engine that can be explored by dragging the map with the mouse. Please see the fiddle below and drag away:

http://jsfiddle.net/kHydg/14/

The code broken down is (CoffeeScript):

The draw function

draw = ->
  requestAnimFrame draw
  canvas.width = canvas.width

  for row in [0..width]
    for col in [0..height]
      xpos = (row - col) * tileHeight + width
      xpos += (canvas.width / 2) - (tileWidth / 2) + scrollPosition.x
      ypos = (row + col) * (tileHeight / 2) + height + scrollPosition.y
      context.drawImage(defaultTile, Math.round(xpos), Math.round(ypos), tileWidth, tileHeight)

Mouse drag-scrolling control

scrollPosition =
  x: 0
  y: 0

dragHelper =
  active: false
  x: 0
  y: 0

window.addEventListener 'mousedown', (e) =>
  handleMouseDown(e)
, false

window.addEventListener 'mousemove', (e) =>
  handleDrag(e)
, false

window.addEventListener 'mouseup', (e) =>
  handleMouseUp(e)
, false

handleDrag = (e) =>
  e.preventDefault()
  if dragHelper.active
    x = e.clientX
    y = e.clientY
    scrollPosition.x -= Math.round((dragHelper.x - x) / 28)
    scrollPosition.y -= Math.round((dragHelper.y - y) / 28)

handleMouseUp = (e) =>
  e.preventDefault()
  dragHelper.active = false

handleMouseDown = (e) =>
  e.preventDefault()
  x = e.clientX
  y = e.clientY
  dragHelper.active = true
  dragHelper.x = x
  dragHelper.y = y

The Problem

As you can see from the fiddle the dragging action is ok but not perfect. How would I change the code to make the dragging action more smooth? What I would like is the point of the map you click on to stay under the mouse point whilst you drag; the same as they have done here:  http://craftyjs.com/demos/isometric/


texts: Why does SDL_RenderCopy result in a blank screen?

texts:
I'm trying to render a texture(picture), but SDL_RenderCopy keeps the window's background black.

Here's the relevant code:

SDL_Rect rect; rect.x = 0, rect.y = 0;
while(!quit)
{
    SDL_RenderCopy(g_renderer, g_texture, NULL, &rect);
    SDL_RenderPresent(g_renderer);
    // Window stays dark although i've rendered via RenderCopy
    SDL_Delay(500);

    while(SDL_PollEvent(&event) != 0)
    {
        if(event.type == SDL_QUIT)
            quit = true;

        else if (event.type == SDL_KEYDOWN)
            move_picture(event.key.keysym.sym, rect);
    }
}

If I change the SDL_RenderCopy function call to:

SDL_RenderCopy(g_renderer, g_texture, NULL, NULL);

The picture is visible in the center of the window, but its not the result I'm looking for, as I would want the image to render to the position I set to my rectangle.

After a couple of searches I've found that this is a known behavior.
I've tried changing the way I'm loading a texture from CreateTextureFromSurface to IMG_LoadSurface, but the rendering still doesn't work.


texts:
I am making Sniper game in unity 3d. In this game zombies will come randomly towards the sniper and sniper have to kill them. I am using RAIN(indie) for path finding. It works best when zombies are few . As I increase the Zombies( that is 10) the performance decrease a lot. The fbs drops to 25.

I want to know is there any technique or steps so I can improve fps
Any other technique/algorithm that I can use for pathfinding weith good fps.

PS

I already remove Sensor component from AI.
FPS of game without AI is 61


texts:
So I have a fullscreen triangle shader like this:

#ifndef FULLSCREEN_TRIANGLE_VERTEX_HLSL
#define FULLSCREEN_TRIANGLE_VERTEX_HLSL

// Variation on Timothy Lottes FXAA vertex shader, for CCW frontface
float4 vs_main(uint VertexID: SV_VertexID) : SV_Position
{
    return float4(float2(((VertexID << 1) & 2) * 2.0f, (VertexID == 0) * -4.0f) + float2(-1.0f, 1.0f), 0.0f, 1.0f);
}

#endif

This helps me during deferred shading, since I can just do like this in the pixel shader:

float4 ps_main(float4 position : SV_Position) : SV_Target0
{
    float ssao = 1.0;
    if (gUseSSAO)
    {
        ssao = gSSAOTexture[uint2(position.xy)].r;
        ssao = (clamp(1.0 - (1.0 - ssao), 0.0, 1.0) + 0.1) / (1.0 + 0.1);
    }

    return gDiffuseTexture[uint2(position.xy)] * ssao * gAmbientLight;
}

SV_Position automatically gives me the screenspace position of the pixel.
Now some of my alghorithms require texture coordinates. I know this is simply (screenspacePosition.xy / textureSize.xy) but I want to avoid those instructions in my pixel shader. Is there some system-provided value (like SV_Position) or any neat way to enhance the fullscreen vertex shader to provide me with texture coordinates aswell?


texts: Error stopping me from opening Xenko editor

texts:
I have just recently downloaded the Xenko game engine.

The error is here:

[C:\Users\bigki\Documents\Xenko Projects\MyGame5\MyGame5.sln.metaproj(0,0)]: Error:The specified solution configuration "Debug|HPD" is invalid. Please specify a valid solution configuration using the Configuration and Platform properties (e.g. MSBuild.exe Solution.sln /p:Configuration=Debug /p:Platform="Any CPU") or leave those properties blank to use the default solution configuration.

This error stops me from even opening the editor.

I have Visual Studio 2019 installed. I have tried reinstalling Xenko, to no avail.
Anyone got a solution to this error? I cannot seem to find an answer anywhere (i.e Xenko Forums, StackOverflow, this website).


texts: RPG Data (Skills, Monsters, Items, Equippables)

texts:
I'm creating a simple RPG type game. I've dabbled with the idea of just loading all the skills, monsters, items and so on at once. However, to do that seems horrible wasteful since I would have potentially hundreds of things in memory that may not necessarily be used just for the battle system.

I'm pretty close to finishing the battle system, I just need to figure out how to handle the data prior.

So would it be best just to just access the disk to load this information in when I need it?   I was considering porting this to another device after I get it working on a PC.

I was looking at the decompilation of Pokemon Red and I'm not exactly sure how they managed to do it either. Given that the RAM for the Gameboy was 8 kilobytes (32 if expanded).

Any pointers (no pun intended) or ideas?


texts: Why does my HTML5 game loop (with masking) run slowly?

texts:
I have a game loop like so:

setInterval(function()
{
    context.save();
    context.rect(26, 144, 745, 400);
    context.clip();
    context.drawImage(myImage, 100, 100, 900, 900);
    context.restore();
}, 40);

As it runs the canvas gradually slows down to a stop. If I put the drawImage outside of the clipping then it runs indefinitely at the correct speed. Is there something I'm doing wrong?


texts: How to determine what color will be written into single pixel framebuffer?

texts:
I thinking about rendering into single pixel (1x1) framebuffer.
For example we have two triangles which covers whole NDC area, one is green second red.

What color will be written to 1x1 framebuffer? As far as I understend graphic API (no matter which) tries to put whole scene in to given framebuffer, in our example, into single pixel. But I can't figure how GPU will choose what should  be written into that pixel.


texts: What backwards compatibility to specify for an app for iOS and Android?

texts:
I'm having an app built, I'm not a programmer and I dont know exactly what to specify.

I want it to work on iPhones and iPads and iPod touches and also on Android devices - tablets as well as smartphones, and the Kindle Fire.

What backwards compatibility do I need to specify, at a sensible level?


texts: Why the renderers Renderer[] array are all null?

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

public class LightsEffect : MonoBehaviour
{
    public List<UnityEngine.GameObject> waypoints;
    public int howmanylight = 5;
    public Generatenumbers gn;
    public bool changeLightsDirection = false;
    public float delay = 0.1f;

    private List<UnityEngine.GameObject> objects;
    private Renderer[] renderers;
    private int greenIndex = 0;
    private float lastChangeTime;

    private void Start()
    {
        //waypoints = new List<UnityEngine.GameObject>();
        objects = new List<UnityEngine.GameObject>();

        if (howmanylight > 0)
        {
            UnityEngine.GameObject go1 = UnityEngine.GameObject.CreatePrimitive(PrimitiveType.Sphere);
            duplicateObject(go1, howmanylight);
            LightsEffects();
        }
    }

    private void Update()
    {
        LightsEffectCore();
    }

    public void duplicateObject(UnityEngine.GameObject original, int howmany)
    {
        howmany++;
        for (int i = 0; i < waypoints.Count - 1; i++)
        {
            for (int j = 1; j < howmany; j++)
            {
                Vector3 position = waypoints[i].transform.position + j * (waypoints[i + 1].transform.position - waypoints[i].transform.position) / howmany;
                UnityEngine.GameObject go = Instantiate(original, new Vector3(position.x, 0, position.z), Quaternion.identity);
                go.transform.localScale = new Vector3(0.3f, 0.1f, 0.3f);
                objects.Add(go);
            }
        }
    }

    private void LightsEffects()
    {
        renderers = new Renderer[objects.Count];
        for (int i = 0; i < renderers.Length; i++)
        {
            renderers[i] = objects[i].GetComponent<Renderer>();
            renderers[i].material.color = Color.red;
        }

        // Set green color to the first one
        greenIndex = 0;
        renderers[greenIndex].material.color = Color.green;
    }

    private void LightsEffectCore()
    {
        // Change color each `delay` seconds
        if (Time.time > lastChangeTime + delay)
        {
            lastChangeTime = Time.time;

            // Set color of the last renderer to red
            // and the color of the current one to green
            renderers[greenIndex].material.color = Color.red;
            if (changeLightsDirection == true)
            {
                Array.Reverse(renderers);
                changeLightsDirection = false;
            }
            greenIndex = (greenIndex + 1) % renderers.Length;
            renderers[greenIndex].material.color = Color.green;
        }
    }
}

In this line if for example objects count is 5 then there will be 5 renderers but they will be all null.

renderers = new Renderer[objects.Count];


texts:
I have a class with three fields:

StartingAngleOnRotationPlane is 180
MinimumRotatedAngleX is 0
MaximumRotatedAngleX is 140

Here is the offending code:

public virtual float ClampRotatedDegreesWithinAllowedRange()
{
    float rotatedAngle = this.transform.GetRotatedAngleOnXPlane();
    Debug.Log("Rotated " + rotatedAngle);

    float clampedRotatedAngle =
        Mathf.Clamp(
            AngleNormaliser.BetweenNegativeAndPositive180(this.StartingAngleOnRotationPlane + rotatedAngle),
            this.MinimumRotatedAngleX,
            this.MaximumRotatedAngleX);

    return clampedRotatedAngle;
}

Here is the debug window:

As you can see, when the breakpoint was hit, rotatedAngle was -178.9446.

To calculate clampedRotatedAngle, rotatedAngle is added to StartingAngleOnRotationPlane, supplied to a method called AngleNormaliser.BetweenNegativeAndPositive180(float input), and then clamped between MinimumRotatedAngleX (0) and MaximumRotatedAngleX (140).

Here is the code for AngleNormaliser.BetweenNegativeAndPositive180(float input):

public static float BetweenNegativeAndPositive180(float angleBetween0And360)
{
    while (angleBetween0And360 > 180)
    {
        angleBetween0And360 -= 360;
    }

    while (angleBetween0And360 < -180)
    {
        angleBetween0And360 += 360;
    }

    return angleBetween0And360;
}

Here is the debug window when AngleNormaliser.BetweenNegativeAndPositive180(float input) was invoked:

By the time the return statement was hit, the result 1.055389 should be returned and assigned to the variable clampedRotatedAngle, since 1.055389 is within the clamping range (0 - 140).

However, that was not the case:

As you can see, clampedRotatedAngle was still zero.

In fact, clampedRotatedAngle is always zero, regardless of what I feed into the Mathf.Clamp function:

How can I fix this?


texts: GLFW is clearly an OpenGL framework, which means we are working with graphics card. How input gets handled then?Seems like it handles all of the controllers on our system, not only graphics card.


texts: Unity Transport Layer API - How to manage client-server connections

texts:
I am currently working on a "Master server" system for our Unity Game using Unity's Low Level "Transport layer API" for networking.

My problem is that I would like to prevent clients from connecting to eachother. I have tried not giving them a port on the Addhost() call, but it doesn't seem to change anything. They also do not seem to detect the connections, so basically I find myself with NetworkTransport.Connect(..) calls that work (the error byte is 0, meaning no error) but no actual connections. I don't understand what's going on.

I can't really show my code because it's quite long, but here's how it works, in summary :

The Clients objects initialise a Socket as normal with only one Reliable channel, no port, and one connection allowed by default. Then they have the ability to connect to another socket, as you'd expect. My problem COULD be coming from there : for testing purposes the IP I use for testing is 127.0.0.1. What I do not understand is, how can it "find itself" when it is not bound to any port ? And more importantly how can it NOT find the Master Server object whose socket IS bound to a port ?

Speaking about Master Server, it's an object that also initialises its socket, but with a port and many allowed connections.

When a client connects and the connection did not yield any errors, it considers the connection to the Master server to be successful and proceeds sending a message containing some information for the server about this client : the username chosen by the player for example.

When the master server receives a connection event, it registers the received ConnectionID and waits for more information from that same connection, for example the aforementioned username.

Both the client and the server handle receiving messages with the NetworkListener class (Static). On each frame it executes the Listen() method which executes a "normal" NetworkTransport.Receive() body. I can give you that part of the code as it is fairly common in design :

public static void Listen()
{
    int recHostID;
    int recConnectionID;
    int recChannelID;
    byte[] buffer = new byte[1024];
    int recDataSize;
    byte error;
    NetworkEventType e = NetworkTransport.Receive(out recHostID, out recConnectionID, out recChannelID, buffer, 1024, out recDataSize, out error);
    Debug.Log("Listening");
    switch(e)
    {
        case (NetworkEventType.Nothing):
            break;
        case (NetworkEventType.ConnectEvent):
            Debug.Log("Connection established. ConnectionID = " + recConnectionID);
            if (OnConnectionReceived != null)
            OnConnectionReceived(recHostID, recConnectionID, recChannelID);
            break;
        case (NetworkEventType.DataEvent):
            Debug.Log("Received data !");
            BinaryFormatter f = new BinaryFormatter();
            MemoryStream stream = new MemoryStream(buffer);
            Message = f.Deserialize(stream) as NetworkMessage;
            break;
        case (NetworkEventType.DisconnectEvent):
            Debug.Log("Connection terminated. ConnectionID = " + recConnectionID);
            break;
    }
}

Network message is a simple data structure which contains a ConnectionID (the one it's from), a message title and content. The title is used to determine the general purpose of the message. The content is the rest of the information.

What happens in my current build of the client :

The user is prompted to enter a username, then he clicks "Search for match". The search for match button is supposed to trigger the connection to the Master Server. The logs say that the connection was successful (as no errors are detected) but no Connection event is received on either side. This of course prevents everything else from working.

If you need further description of the problem just ask and I'll answer ASAP.

Thanks a lot in advance !


texts:
How is a Behavior Tree iterated in a game?  For example, let's assume you have an extremely large Behavior Tree with about a hundred Actions/Conditions.  If we were to run one action or condition every Frame Tick that would take about 100 Frames to reach the very last Action in the Tree.

So my question is, do we iterate the whole tree until we find a "runnable" action, run it, then return.  Or do we iterate the whole tree and run as many actions as we can before getting to an action that takes multiple frames/updates to finish running?


texts: OnCollisionEnter not called when two colliders collide

texts:
In my 2D game, there is a ball with a circle collider ,and a platform with a box collider.

The ball has a material for bounciness and a rigidbody2D. The platform only has the box collider.

I find it to be as simple as could be, but it's not working for some reason, so apparently it's not that simple. Here's the C# code snippet found in the ball class which is attached to the ball game object:

void OnCollisionEnter(Collision other)
{
    Debug.Log("Hit");
    animator.Play("Bounce");
}

Why isn't the function being called on collision? Any idea would be appreciated.


texts:
I'm looking at how to implement a vision cone for my AI. Everything I look at talks about a forward vector, but in my situation, and I'm not that great with math, I have a vector but it doesn't give any orientation just the 3D point of where the entity is. The entity does have a separate rotation value. When people talk about forward vector are they talking about the rotation vector?

So if I just have a rotation vector and a location vector how can I make a vision cone in 3D from those values with say a variable degree of vision in both "left/right" and "up/down"?

I have some math functions available like ATan2()/Tan(). Not 100% sure how those play into this though.


texts: How to flip a sprite that is noncentered

texts:
I have a sprite that I want to flip horizontal but I don't want it to look like the sprite is "changing position". I have code that changes the sprite horizontal direction depending if you go right or left, the problem is that it looks like the character is changing position.

I don't understand how I can solve this problem cause changing the origin is not doing anything when fliping the texture. Meaning it doesn't matter if I change the origin cordinates. How should I go about to flip horizontal but to not make it look like it is "changing position"
Edit
var temporg = Origin;
temporg.X = currenttexture.Width / 2;
temporg.Y = currenttexture.Height / 2;
Origin = temporg;
Position = new Vector2(Origin.X, Origin.Y);

And I have a class called AnimationHandler with a draw function that draw out my texture like this
spriteBatch.Draw(CurrentTexture, position, null, Color.White, 0f, Origin, 1f, spriteEffect, 0f);

Where 'spriteEffect' is the horizontal flip.


texts: Unity 2D camera drifts from player as speed increases

texts:
I have a dilemma that I did not have in XNA before porting my game to Unity.

First-- my goal is to mimic Super Mario World 2's camera tracking in x. The camera tracks to 1 block ahead of the player, to the left or right, depending on the direction, even if the player stops moving during the camera tracking process, otherwise I would simply make the camera a child of the character and then be done.

As the speed of my character increases, the camera drags behind. The distance (lag) between the camera and the player increases with speed, but catches up instantly when the player stops moving. I figure this is because the FixedUpdate call is somehow getting the last player position from my controller script.

This did not occur in my XNA project, and the algorithms are essentially the same.

cameraTargetX = position.transform.x - margin;

in this case the margin would be +2 blocks or -2 blocks depending on direction. Even if I get input for movement into fixed update in my player script, I still get the same delay amount. Is there a way to essentially lock the camera to a position directly in front of or behind the player without gradual delay?

If one could point me to an example of a detailed or elaborate 2D platformer with similar camera controls, that would be much appreciated since the Unity 2D example platformer's camera script is really nothing like what I'm trying to do here.


texts: "Game Property Values" for online game on Database or somewhere else?

texts:
I'm working on a online game but,
what would be the best way to store values like damage,movespeed,turnrate, and so on.. ?

My answer would be, to store them in a Database, so they can easily be changed by any developer and  are "unreachable" for the useres, or are there better ways to do that?


texts: How to correctly check for HW T&L on Direct3D?

texts:
In theory, to check for HW T&L in Direct3D, one calls IDirect3D9::GetDeviceCaps and checks for the HWTRANSFORMANDLIGHT flag to be set in the returned structed.

However, the documentation states:

  The application should not assume the persistence of vertex processing
  capabilities across Direct3D device objects. The particular
  capabilities that a physical device exposes may depend on parameters
  supplied to CreateDevice. For example, the capabilities may yield
  different vertex processing capabilities before and after creating a
  Direct3D Device Object with hardware vertex processing enabled. For
  more information see the description of D3DCAPS9.

If I understand this correctly, GetDeviceCaps could return that HW T&L is not supported before creating a device, and return that it is supported after. But if I can create a device with HW T&L successfully, then there is no point checking for HW T&L support!

So my question is, is there any purpose to checking for HW T&L using GetDeviceCaps, or am I better off just attempting to create the device with HW T&L and seeing if it succeeds?


texts:
I'm attempting to write a chunk based map system for a game, where as the player moves around chunks are loaded/unloaded, so that the program doesn't run out of memory by having the whole map in memory.

I have this part mostly working, however I've hit a wall regarding how to represent the contents of each chunk in memory because of my so far limited understanding of OOP languages.

The design I have currently has a ChunkManager class that uses a .NET List type to store instances of Chunk classes. The "chunks" consist of "blocks". It's similar to a Minecraft style game.

Inside the Chunk classes, I have some information such as the chunk's X/Y coordinate etc, and I also have a three dimensional array of Block objects. (Three dimensional because I need XYZ values)

Here's the problem:

The Block class has some basic properties, and I had planned on making different types of blocks inherit from this "base" class. So for example, I would have "StoneBlock", "WaterBlock" etc.

So because I have blocks of many different types, I don't know how I would create an array with different object types in each cell.

This is how I currently have the three dimensional array declared in my Chunk class:

private Block[][][] ArrayOfBlocks;

But obviously this will only accept Block objects, not any of the other classes that inherit from Block.

How would I go about creating this? Or am I doing it completely wrong and there's a better way?


texts: Unity3D: Determine vectors parallel to terrain

texts:
I am trying to determine vectors that relate the height map information from a Terrain built in Unity to vectors that are parallel to the slope of the terrain.

i.e. From the Unity built terrain, whose contour map looks like the one in the Figure below, I want to draw the vector which is along the slope of the terrain, in the direction that is perpendicular to the contour lines.

How would I do this? I've found a question here that includes an answer which supplies code to find the contour lines from a height map.

Does any one know how to find the vectors?

Thanks.


texts: prefab editor not working for NGUI in unity2018

texts:
i just updated my project from unity5 to unity 2018. my project uses ngui as UI solution. eveything works fine in updated version but when i want to edit prefabs in prefab mode i get this message:

is there any idea about cause of this problem and how to solve it?

i looked for updating ngui for unity 2018 but because of many changes ngui has, it causes lots of problem in project that takes lots of time to solve the mall


texts:
I have an object the is a perfect circle.  The object is moving left, right and jumping with collision detection.  What I am trying to do now is rotate the object while it is moving, so it looks like rolling.

This is the code that I have so far:

key_left = keyboard_check(vk_left);
key_right = keyboard_check(vk_right);
key_jump = keyboard_check_pressed(vk_space);

//1  right, -1 left
var move = key_right - key_left;
hsp = move * walkspd;
vsp = vsp + grv;

if(place_meeting(x, y + 1, oWall)) && (key_jump)
{
    vsp = -7;
}

//horizontal collisions
if (place_meeting(x + hsp, y, oWall))
{
    while (!place_meeting(x + sign(hsp), y, oWall))
    {
        x = x + sign(hsp);
    }
    hsp = 0;
}
x = x + hsp;

//vertical collisions
if (place_meeting(x , y + vsp, oWall))
{
    while (!place_meeting(x, y+ sign(vsp), oWall))
    {
        y = y + sign(vsp);
    }
    vsp = 0;
}


texts: How to encode a save game / game state as a string?

texts:
I'm building an HTML game. For this game I want to implement a save-feature that should work like in some already existing games:

The user can chose export, this will create a string, representing the game state (I guess).
This string can be pasted into an import input and will load the save game.

I thought about storing the state in a JSON, minifying it, stringifying and encoding it in Base64.
But I don't think this is a good idea, users could easily cheat in this game by decoding the string, changing whatever they want, encoding it again and loading this string.

I already tried generating save files in games with this feature and decoding them in Base64 which didn't work, so I assume they use a different encoding.

How can I encode the JSON like this?


texts: Cook Torrance model implementation : black specular light

texts:
I am trying to implement the Cook-Torrance model, and this is how I calculate the parameter Rs:

float Rs(float m,float F,vec3 N, vec3 L,vec3 V, vec3 H)
{
    float result;
    float NdotV= dot(N,V);
    float NdotH= dot(N,H);
    float NdotL= dot(N,L);
    float VdotH= dot(V,H);
    float Geom= min(min(1.0, (2.0*NdotV*NdotH)/VdotH), (2.0*NdotL*NdotH)/VdotH);
    float Rough= pow(1.0/(pow(m,2.0)*pow(NdotH,4.0)), ( pow(NdotH,2.0)-1.0)/( pow(m,2.0)*pow(NdotH,2.0)));
    float Fresnel= F + pow(1.0-VdotH,5.0) * (1.0-F);
    return (Fresnel * Rough * Geom)/(NdotV*NdotL);
}

I apply this formula:

Where I set m to 0.5 and F0 to 2.0.

But I think it's wrong because I'm getting a black area where there should be the specular light:

PS: With OpenGL 2.1, GLSL 1.20.


texts: What does "kTriangles/s" mean in hardware graphics benchmark reports?

texts:
I've looked around and found several sites offering benchmarking statistics for mobile platforms and I've been seeing the unit of measure as "kTriangles/s". Originally I misread this, missing the 'k'; does this translate to "thousand(s) of triangles/s", e.g.:

8902 kTriangles/s = 8,902,000 triangles/s

(I'm pretty sure that my interpretation is correct, but I hope someone can confirm this for me)


texts:
There is plenty of information on what deferred rendering is but there is a lack when it comes to deferred lighting and the information that there is there is not clear.

My question is simple, what is deferred lighting and what is its advantage and disadvantage.


texts: OpenGLES 2.0: Rendering Multiple Sprites - Texel Corruption

texts:
I'm having a tremendous time getting the second (or additional) sprites in my game engine to render properly.  The first one always works great: it is positioned and sized properly in screen coords, and its texture is mapped properly.  When I add a second sprite to the world, its texture does not get mapped properly.  If I reverse the two sprites render orders, the sprite that was rendered second previously (and had corrupt texture mapping) is now correct, and the other sprite is now corrupt.

I think it has to do with something in my shader not getting cleared out properly before it is used again.  I have to admit, I'm fairly new to shaders.  Interestingly, I'm building this engine to support both ES1.1 and ES2.0, and the same code works great in ES1.1 for multiple sprites.

I'll attempt to provide relevant code snippets below.  Any suggestions would be great - I've browsed dozens of good forums and Stack Exchange.  Is there perhaps a call I should be making between primitive renders to clean out the shaders?

Here's the snippet for rendering in ES2.0

void Sprite::Render(GLuint shaderProgram, UniformHandles* uniforms, AttributeHandles* attributes)
{
// Use the shader we were sent
glUseProgram(shaderProgram);

// Enable transparent blending
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

// Performance: could pull this out and only recalculate when moved
PVRTVec2 bottomLeftPos = PVRTVec2((m_viewDims.x - m_position.x) / m_viewDims.x,
                                      ((m_viewDims.y - (m_position.y - m_drawDims.y)) / m_viewDims.y));

PVRTVec2 topRightPos = PVRTVec2((m_viewDims.x - (m_position.x + m_drawDims.x)) / m_viewDims.x,
                                    (m_viewDims.y - m_position.y) / m_viewDims.y);

// Draw the quad for ES2 (positioning is not based on these values: do not change)
DrawQuad((bottomLeftPos.x * 2.0f) - 1.0f, (bottomLeftPos.y * 2.0f) - 1.0f, (topRightPos.x * 2.0f) - 1.0f, (topRightPos.y * 2.0f) - 1.0f, m_textureResource->texture, uniforms, attributes);

// Turn off blending
glDisable(GL_BLEND);

}

And here's the snippet for DrawQuad()

void Sprite::DrawQuad(float x1, float y1, float x2, float y2, GLuint texture,
                  UniformHandles* uniforms, AttributeHandles* attributes)
{

    // Set the uniforms for rectangle position and width
    // Landscape
    glUniform2f(uniforms->LowerLeft, -y1, x1);
    float scaleMatrix[4] = { 0, x2 - x1, y1 - y2, 0 };
    glUniformMatrix2fv(uniforms->ScaleMatrix, 1, GL_FALSE, scaleMatrix);

    // Use the given texture
    glActiveTexture(GL_TEXTURE0);
    glBindTexture(GL_TEXTURE_2D, texture);

    // Bind the vertex buffer object
    glBindBuffer(GL_ARRAY_BUFFER, m_vbo);
    glEnableVertexAttribArray(attributes->in2DVertex);
    glEnableVertexAttribArray(attributes->inSpriteTexCoord);
    glVertexAttribPointer(attributes->in2DVertex, 2, GL_FLOAT, GL_FALSE, sizeof(GL_FLOAT) * 4, 0);
    glVertexAttribPointer(attributes->inSpriteTexCoord, 2, GL_FLOAT, GL_FALSE, sizeof(GL_FLOAT) * 4, (unsigned char*) (sizeof(GL_FLOAT) * 2));

    // Draws a short triangle strip
    glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);

    glDisableVertexAttribArray(attributes->in2DVertex);
    glDisableVertexAttribArray(attributes->inSpriteTexCoord);
    glBindBuffer(GL_ARRAY_BUFFER, 0);
}

And finally the vertex shader and fragment shader for 2D sprites:

Vertex Shader
    attribute highp vec2    in2DVertex;
    attribute highp vec2    inSpriteTexCoord;

uniform highp vec2      LowerLeft;
uniform highp mat2      ScaleMatrix; // Width/height and screen rotation

varying mediump vec2    TexCoord;

void main()
{
   gl_Position = vec4(ScaleMatrix * in2DVertex + LowerLeft, 0, 1);
   TexCoord = inSpriteTexCoord; // formerly in2DVertex
}

Fragment Shader
    uniform sampler2D  sTexture;

varying mediump vec2    TexCoord;

void main()
{
    gl_FragColor = texture2D(sTexture, TexCoord);
}


texts: Why do I not see the back of a model in the model

texts:
I have created a die in blender, that uses two materials.  One material is transparent and the second is opaque.

When I look throught the die, I expect to see the opaque parts blocking the view, but I do not see them at all.

As you can see in the image above, the 6 dots on the back of the die are not shown, it just looks like it is empty.

What can I do to fix this?


texts: 2D Island generator algorithm - chances of tile becoming land

texts:
I am developing my first island generator (in c#). I am using this algorithm as my basic idea :
http://www.funstormgames.com/blog/2012/09/procedural-island-generation-for-ludum-dare-24/

Basically you loop around the tiles in a spiral shape, adding land based on chances - the more land the current tile is touching, the more chances of this tile becoming land. However, I don't know how to work with the chances - whatever I put I am never satisfied with my result.

If you havent worked using this algorithm, you can't really help me with the numbers, but a recomendation for a new approach would be great!

I am using a function to determine each tile - passing an argument called potentialChance.
For the first "circle" or round around the starting island I put a 25 potential chance.

This potential chance was at first multiplied with the number of land tiles the current grid we are potentially changing into land is touching. So, if a grid has 3 surrounding tiles of land, its chance would be 75% (I generate a random number up to 100 and compare).

I was not satisfied with too many islands I got, and I was changing the potential chance while testing. So instead of multiplying the number of tiles with the potential chance - I tried a different approach.

I would have a quotient of ie 0.7, and for each surrounding land tile, I would multiply  the quotient by ie 1.5, and then multiply that number with the potential chance. Still, I was not too satisfied.

I know my algorithm works properly (I have debugged and seen the results), but my numbers are not too good.

If anyone worked with this same logarithm, I would love to see the approach and numbers! Otherwise, would you suggest working on a new algorithm? I'm new in game development so...


texts: Inspite  my ground and cube contains colliders as i apply rigidbody it falls down....use gravity


texts: How can I create the arriving/ engaging in combat movement like in StarCraft 2?

texts:
I currently have two armies (smaller scale) crashing into each other. They will usually form a line of units fighting. I have no idea how to handle a unit coming from behind the line to properly go around its allies to reach the enemies. Like in this position, where a new unit approaching from the green army needs to navigate around the battle front to reach the red enemies:

StarCraft 2 handles this beautifully, as seen here:

I've read that SC2 uses steering for local avoidance and A* and some other methods to plan out the paths. Which all is perfectly clear, but I haven't found anywhere any details on engaging the enemy.
This is what I have, it's been a month and I still haven't solved this specific issue.

How is it possible to do continuous checks of possible destinations before engaging the enemy, wouldn't it be too costly? To clarify, in the video of the Zerglings vs Zealots, they first engage each other and form a line, all the other units that come after them will go around the line, but, if space opens in the line they will immediately go towards it. This kind of arrival behaviour is briefly explained in their GDC talk, they have a cone of vision in which they do checks. The only ideas I had was

Have a cone of vectors (in the direction of Velocity) and do checks for each vector to see if it could provide a favorable position to move to
issue: Cannot figure out the math to create offsetted (by an angle) vectors, but it seems like a pretty decent solution

Have a spatial query in a rectangle to where the unit is moving
issue: How do I check for an empty space? I can get all entities in that rectangle but how can I check for empty places and score them (how favorable are they)? Are they even reachable, I'd still need some kind of raycast like with the first option

I have circlular collision shapes, seperation and goal following in place. I somewhat have introduced a goal system that should further spread the units, but as it stands I still lack the arrival behaviour described in the GDC talk.


texts:
Im going to write an MMO server for a game, however in my last attempt to do this I used mysql with xampp-server and the game-server was getting the data offline tru mysql(xampp server was offline).

I was wondering if this will be fast enough when hundreds of players are constantly sending request to the game-server and the game-server to mysql(offline) for pulling or saving data(ex. constantly saving position for each player etc etc)

If not what would be an appropriate way to archive this? Thanks


texts: How do you refer to the objects covering the ground?

texts: Newbye here. In the industry lingo, what is the best way to indicate the objects covering the ground (trees, rocks, ...)? Is props OK?


texts: Game development with D programming language

texts:
I have recently found out about D programming language and its basic features. It seems D is quite powerful alternative for C++ and more effective at some points. Also D can interface to C, but interfacing to C++ is limited.

The only engine I found out is D Game Engine, but it is in an early pre-alpha state and I'm not sure it's developing anymore.

Are there any 3D, physics or game engines written in D or at least wrappers for engines in other languages? Is it possible to use with D such engines like irrlicht, Ogre3d or Torque 3D without almost complete rewriting it?


texts:
Do I need to learn C++ to use Open GL?
Do I need to learn C++ to use Open GL?


texts:
I want my NavMeshAgent to jump when Space key is hit.

The Script (in Unityscript) I tried is :

var isJump:boolean=false;

function Update () {

  if(Input.GetKeyDown(KeyCode.Space)){

     GetComponent.<UnityEngine.AI.NavMeshAgent>().enabled=false;
     GetComponent.<Rigidbody>().isKinematic=false;
     GetComponent.<Rigidbody>().AddForce(0,400,0);
     isJump=true;

 }
}

 function OnCollisionEnter(col:Collision){

   if(col.gameObject.layer==4 && isJump){

     GetComponent.<UnityEngine.AI.NavMeshAgent>().enabled=true;
     GetComponent.<Rigidbody>().isKinematic=true;
     isJump=false;
  }

}

The ground where the NavMeshAgent stands is in layer 4. But the Agent is not jumping in the first place. But when I don't used the OnCollisionEnter function it jumps. But I need some function to return it to the initial state.

I tried a print("something") inside if statement of OnCollisionEnter function and it prints it as soon as I hit Space. That if statement should have executed when the object jumped and collides with the ground.

How to make it work?


texts: Portal 2 Authoring Tools: func_instance_io_proxy not working?

texts:
I have a func_instance (which I made myself) of a door in my map. It is supposed to open when a cube is fizzled. I also put a checkmark indicator to make sure I had the cube's logic correct. When the cube is fizzled, the checkmark indicator lights up, but the door does not open. To make sure the door was working, I put a logic_auto into the prefab which opened the door when the map loaded. This worked correctly. I therefore think that there is something wrong with the func_instance_io_proxy, but I do not know what. Here are some screenshots:

The cube targets the openDoor relay's trigger input via the func_instance_io_proxy. It also targets the checkmark indicator, which properly lights up when the cube is fizzled.

My door func_instance. The relay on the left opens the door, and the one on the right closes it.

The logic_auto targets the closeDoor relay on startup, which does execute properly, as the door is closed when I go to test the map.

Finally, the func_instance_io_proxy targets the openDoor's trigger input. However, when I try and access it via the cube, it does not work, and the door does not open.

*By the way, I am running this on linux via wine, which is why it looks like windows 98

**Off-topic question, is this the right place to post this, since it is technically map making, not game development?


texts:
I have tried to set Rigibody enabled to false with this code but I get multiple errors. What is the correct version of this code?

GetComponent<RigidBody>().Enabled = false;


texts:
I am trying to create a platform game and doing wrong collision detection with the blocks.

Here's my code

// Variables
GTimer jump = new GTimer(1000);
boolean onground = true;

// The update method
public void update(long elapsedTime){
    MapView.follow(this);
    // Add the gravity
    if (!onground && !jump.active){
        setVelocityY(4);
    }
    // Jumping
    if (isPressed(VK_SPACE) && onground){
        jump.start();
        setVelocityY(-4);
        onground = false;
    }
    if (jump.action(elapsedTime)){
        // jump expired
        jump.stop();
    }
    // Horizontal movement
    setVelocityX(0);
    if (isPressed(VK_LEFT)){
        setVelocityX(-4);
    }
    if (isPressed(VK_RIGHT)){
        setVelocityX(4);
    }
}

// The collision method
public void collision(GObject other){
    if (other instanceof Block){
        // Determine the horizontal distance between centers
        float h_dist = Math.abs((other.getX() + other.getWidth()/2) - (getX() + getWidth()/2));
        // Now the vertical distance
        float v_dist = Math.abs((other.getY() + other.getHeight()/2) - (getY() + getHeight()/2));
        // If h_dist > v_dist horizontal collision else vertical collision
        if (h_dist > v_dist){
            // Are we moving right?
            if (getX()<other.getX()){
                setX(other.getX()-getWidth());
            }
            // Are we moving left?
            else if (getX()>other.getX()){
                setX(other.getX()+other.getWidth());
            }
        } else {
            // Are we moving up?
            if (jump.active){
                jump.stop();
            }
            // We are moving down
            else {
                setY(other.getY()-getHeight());
                setVelocityY(0);
                onground = true;
            }
        }
    }
}

The problem is that the object jumps well but does not fall when moved out of platform. Here's an image describing the problem.

I know I'm not checking underneath the object but I don't know how. The map is a list of objects and should I have to iterate over all the objects???

Thanks


texts: 3d points to rotation matrix of orientation

texts:
I have a vector in a 3D view, defined by a point p1(x1, y1, z1) and a rotation r1(x1, y1, z1). I can get a direction and a yaw. I need that vector to point another point p2 (x2, y2, z2). So I need a new rotation.

Coordinates:
Coordinates are expressed like this: (5, 45, -12)
This refers to the position where X=5, Y=45 and Z=-12. The 3 letters are called “axes”: Y is for the height. X and Z are for the horizontal position.
Rotation:
Yaw and pitch (radians). It can be converted to degrees.

I get this function, where d is the direction (vector between pos1 and pos2):

  d = normalize(d);
  double yaw = Math.Atan2(d.X, d.Y);
  double pitch = Math.Asin(d.Z)

Is it Ok?


texts: Auto-tiling with Yoshi's Island style tiles

texts:
I'm creating a 2D platformer and I'd like to implement an auto-tiling system.  Normally, this wouldn't be particularly difficult.  However, I'd like to have tiles like in Yoshi's Island, where the graphics extend past the actual collidable tile's boundaries.

Consider this image:

Although the eggs and the Piranha Plant are clearly resting on the ground, the flower tiles continue behind them, out of the collidable tile.

I know that it would be simple to do by hand, but extremely time consuming.  Using an auto-tiling algorithm would save me a lot of time and boredom, but I'm not sure where to start.


texts: Check if an object is facing another based on angles

texts:
I already have something that calculates the bearing angle to get one object to face another. You give it the positions and it returns the angle to get one to face the other.

Now I need to figure out how tell if on object is facing toward another object within a specified field and I can't find any information about how to do this.

The objects are obj1 and obj2. Their angles are at obj1.angle and obj2.angle. Their vectors are at obj1.pos and obj2.pos. It's in the format [x,y]. The angle to have one face directly at another is found with direction(obj1.pos,obj2.pos).

I want to set the function up like this: isfacing(obj1,obj2,area){...}
and return true/false depending if it's in the specified field area to the angle to directly see it.

I've got a base like this:

var isfacing = function (obj1,obj2,area){
   var toface = direction(obj1.pos,obj2.pos);
   if(toface+area >= obj1.angle && ob1.angle >= toface-area){
       return true;
   }
   return false;
}

But my problem is that the angles are in 360 degrees, never above 360 and never below 0. How can I account for that in this? If the first object's angle is say at 0 and say I subtract a field area of 20 or so. It'll check if it's less than -20! If I fix the -20 it becomes 340 but x < 340 isn't what I want, I'd have to x > 340 in that case.

Is there someone out there with more sleep than I that can help a new dev pulling an all-nighter just to get enemies to know if they're attacking in the right direction? I hope I'm making this harder than it seems.

I'd just make them always face the main char if the producer didn't want attacks from behind to work while blocking. In which case I'll need the function above anyways.

I've tried to give as much info as I can think would help. Also this is in 2d.


texts:
I have create a 2D game with directx11 and i want to use a depth buffer instead of a painter's algorithm to draw the sprites but i have a problem since i'm not really good with directx 3d programming.
I can create a depthstencilview and it works but look at the following image:

the darker circle is not a semi-circle, they use the same texture and the same mesh: a quad.
First i render the light red circle( with 0.5 depth) and then the darker one(1.0f depth).
the alpha pixels of the first subscribe the depth buffer so the second isn't displayed correctly.
I need aplha pixels don't subscribe depth buffer
I can i set depth stencil / alpha blend state to do this?

Sorry for the bad english


texts:
I searched for a shader, where I can set a solid color, which I can fade in or out like I want. There is not such a thing build in as far as I could see. Now I got this code, which works fine in case of the alpha value, but it turns everything behind upside down. Since I'm absolutely not into shaders, I need help to fix that to a simple alpha shader.

Shader "Unity Answers/Solid Transparency Color"
{
    Properties
    {
        _Color ("Color", Color) = (0.5, 0.5, 0.5, 0.5)
    }

    SubShader
        {
            Tags {"Queue" = "Transparent"}
            ZWrite Off GrabPass { }
            Pass { Fog { Mode Off } Blend SrcAlpha OneMinusSrcAlpha

         CGPROGRAM
         #pragma vertex vert
         #pragma fragment frag

         fixed4 _Color;
         sampler2D _GrabTexture;
         struct appdata
         {
             float4 vertex : POSITION;
         };
         struct v2f
         {
             float4 pos : SV_POSITION;
             float4 uv : TEXCOORD0;
         };
         v2f vert (appdata v)
         {
             v2f o;
             o.pos = mul(UNITY_MATRIX_MVP, v.vertex);
             o.uv = o.pos;
             return o;
         }
         half4 frag(v2f i) : COLOR
         {
             float2 coord = 0.5 + 0.5 * i.uv.xy / i.uv.w;
             fixed4 tex = tex2D(_GrabTexture, float2(coord.x, 1 - coord.y));
             return fixed4(lerp(tex.rgb, _Color.rgb, _Color.a), 1);
         }
         ENDCG
     }
 }
}


texts: Techniques of graphics rendering with single CPU core?

texts:
I am interested in methods of 2d and 3d rendering using single thread on an average CPU (e.g. for programming games for old and low-end PCs).

While I usually have no performance problems when using OpenGL and shaders, I have little understanding about how can real-time 3d, lighting or certain effects (like blur, other convolutions or perspective transformations) be achieved and made fast enough without using GPU.

I am aware of some obvious optimization techniques (precalculating functions, rendering in lower resolution and then stretching, calculating convolutions for each axis separately), but they often do not give enough performance for my applications.

Are there any sources (or keywords for Google) where I can find out about platform-independent rendering optimiztions and algorithms for CPU?


texts: ScreenToWorldPoint(Input.mousePosition) always returns 0 for X and Y coordinates

texts:
I'm trying to convert the mouse position (Input.mousePosition) into world points, but for whatever reason the X and Y coordinates are always, always 0.
Here, I printed mousePosition and ScreenToWorldPoint()'s output:

The -10 in the Z is understandable, but why do I get 0s in X and Y regardless of the actual, varying mouse position?
This is inside a custom display I set inside Game View (1440x3040). I tried Free Aspect, but that didn't change anything.
I tried parenting the script to an empty game object centered on origin just in case, but that didn't do anything either.
The code:
Vector3 mousePos = Camera.main.ScreenToWorldPoint(Input.mousePosition);
Debug.Log(mousePos);
Debug.Log(Input.mousePosition);

Or, more generally:
private bool hitProjectile() {
    bool hit = false;
    Vector3 mousePos = Camera.main.ScreenToWorldPoint(Input.mousePosition);

    Debug.Log(mousePos);
    Debug.Log(Input.mousePosition);

    if ((mousePos.x >= (pt.position.x - radius) && mousePos.x <= (pt.position.x + radius)) &&
        (mousePos.y >= (pt.position.y - radius) && mousePos.y <= (pt.position.y + radius)))
        hit = true;

    return hit;
}

The game is in 2D, the camera is perspective, and I'm using URP. The script is trying to determine if the mouse clicked on a circle (/w a CircleCollider2D).
What the hell is going on? I hope this is not a URP thing. I've had nothing but bad experiences with it.