texts:
I'm using Unity 2017 and am writing a game wherein you shoot a ball, and when said ball hit something (a cube for example), I want it to remain in that position that it hit.

I tried this but it didn't work:

ball.transform.localPosition = gameObject.transform.localPosition;

Something like this picture :


texts:
I'm trying to make a pong game in pygame, but I can't figure out how to put a ball circle, which I can create with pygame.draw.circle into a pygame.Rect object so i can use the colliderect function to manipulate the ball's position.

For example, a rectangle, I can do something like this:

rect = pygame.Rect(255, 255, 100, 100)
pygame.draw.rect(screen, yellow, rect)

When I change the pygame.Rect object position, the drawing primitives position also changes.

How can the same effect be achieved when I want to draw a circle, instead of a rectangle?


texts: Would a custom mod built for RakNet be automatically usable with Unity?

texts:
Context: I'm interesting in developing a security module for servers that handle mobile games, and I'd like it to be usable by the most people possible. So I'm trying to decide what server software I want to build it for.

I'm looking at RakNet, and it's appealing because it's available two ways: independently and as part of the networking solution of Unity3D. So it's software that gets used by developers who want to use Unity3D as well as those who don't.

My question: if I create a modification that implements my security system inside RakNet, will that solution be automatically compatible with Unity also?


texts: How to turn the hotspot on automatically in Unity?

texts:
I have made a simple LAN multi-player game in Unity (just for learning purposes).

This is the main code (for connection):

using UnityEngine;
using System.Collections;

public class StartServer : MonoBehaviour
{
    public Transform Makan;
    public Transform CubeOBJ;
    public string SSS;

    void OnGUI ()
    {
        GUILayout.Box (Network.player.ipAddress);

        if (Network.peerType == NetworkPeerType.Disconnected)
        {
            SSS = GUILayout.TextField (SSS);

            if (GUILayout.Button ("StartServer"))
            {
                Network.InitializeServer(10, 25000);
            }

            if (GUILayout.Button ("Connect"))
            {
                Network.Connect (SSS, 25000);
            }
        }
        else
        {
            if (GUILayout.Button ("creatCube"))
            {
                Network.Instantiate (CubeOBJ, Makan.transform.position, Makan.transform.rotation, 0);
            }
        }
    }
}

It works good. The problem is that in mobile devices I should turn on hotspot by myself for one of the devices.

How can I do this automatically from code?


texts:
I'm looking for a 3D graphics library (not a complete game engine). Preferred a scene graph. Something small (unlike jME, XNA or Unity), that I can easily expand and change.

Preferred features:

Cross Platform
Wrriten in Java/Scala (JOGL or LWJGL), C# (preferred OpenTK), Python or JavaScript/WebGL.
Support for OpenGL is a must. Direct3D is optional.
Some material system
Full support for some model format with full animation support (preferred COLLADA)
Level of Detail (LOD) support
Lighting support
Shaders, GUI, Input and Terrain/Water support are also preferred, but not required

Thanks!


texts:
I am playing around directx lately and I am learning from rasterek.com tutorials. He passes pointers to directx objects (like ID3D11Device, ID3D11DeviceContext etc.) for almost every class he creates. Wouldn't be a better approach to create some kind of singleton or event a simple struct that keeps all of the objects? I don't know too much about game engine designs and I don't understand his purpose, for me it's just more work to do.

Example:
His code:

bool Class::initialize( ID3D11Device* device ) {
    device->doSmth();
}

My idea:

struct DXObj {
    static ID3D11Device* device;
}
bool Class::initialize() {
    DXObj::device->doSmth();
}


texts: Pathfinding with 2D, non-grid based movement over uniform terrain

texts:
I'm looking for the best solution to pathfinding in my game. The map is ultimately grid-based, but entities are positioned using floats, and can move in any direction to any point on the map. The 'ground' in my game has a uniform movement cost, but of course there can be obstacles that block the way. The majority of obstacles will be static, and although there will be other animate entities in the game, I may get away with not considering them - it's an isometric Theme Hospital style strategy game, so no fighting.

Most of the path-finding articles I've seen cover 3D or grid-based 2D movement. Any suggestions for something that might cover my use-case? Many thanks.


texts:
I'm trying to create a WW2 simple game and I'm experience issue creating the light emitted from a Flak Searchlight.

The final lighting effect will be something like this:

http://s1115.photobucket.com/user/k4kittycrew/media/K4KITTY3/Slide2_zpsfccf1590.jpg.html

I know that it is called "volumetric light" and this is not supported by Unity.

Thanks


texts: Hard coded triangle in CG geometry shader doesn't show on screen

texts:
In Unity I'm planning on using a geometry shader for processing points into quads and can't quite figure out why I'm not getting output from my geometry shader. I've edited it down to a minimum working example, as seen here:

Shader "foo/bar"
{
    SubShader{
        Cull Off
        Lighting Off
        ZWrite Off

        Pass{
            CGPROGRAM
                #pragma vertex vert
                #pragma fragment frag
                #pragma geometry geom

                struct appdata {
                    float4 vertex : POSITION;
                };
                struct v2g {
                    float4 vertex : POSITION;
                };
                struct g2f {
                    float4 vertex : POSITION;
                };

                v2g vert(appdata v) {
                    v2g o = (v2g)0;
                    o.vertex = v.vertex;
                    return o;
                }

                [maxvertexcount(4)]
                void geom(point v2g p[1], inout TriangleStream<g2f> tristream)
                {
                    g2f o = (g2f)0;
                    o.vertex = float4(0.1, 0.1, 0, 0);
                    tristream.Append(o);
                    o.vertex = float4(0.1, 0.9, 0, 0);
                    tristream.Append(o);
                    o.vertex = float4(0.9, 0.9, 0, 0);
                    tristream.Append(o);
                }

                fixed4 frag(g2f i) : COLOR
                {
                    return fixed4(1,1,1,1);
                }
            ENDCG
        }
    }
}

I'd expect that to draw a white triangle covering just under half the texture I'm rendering to. Instead it displays all black, just as it was before the shader.

So far I've:

Removed every possible source of culling I can think of
Made absolute sure my setup works when rendering a mesh in a similar fashion
Checked that this is getting input and running
and scoured the very limited amount of documentation available

I'm out of ideas. If anyone has even a minor clue as to what I'm doing wrong please let me know. Thanks.

-Fraser


texts: Unity: how to detect collision occuring on child object, from a parent script?

texts:
I've an enemy, with this structure

Enemy

Body

Head
Arm Left
Arm right

And so on.

I also have a collider for each part of the body.
In my "Enemy" object I've attached a script and in that script I would like to intercept possible collision (a bullet) for body, head, arm, left etc.

Is there a way to do this?


texts: Support of multiple 3d formats in engine

texts:
What is the best practice to add support of loading models from multiple file formats (.obj, .3ds ...)?
What class hierarchy should I use (now I have Mesh class( containing vertex, data ) and MeshLoader class ( doing nothing right now ))?
I do not want to write loaders by myself, so than I have to copy loaded data into my structure.
Possibly you can show some articles explaining it especially Mesh class organization. Thanks in advance.


texts: Technical names for camera styles in 2D games

texts:
In 2D gaming, the camera movement method has a lot do with the play style of the game.  I'm not super familiar with the technical terms for camera styles, so I'm going to describe them in hopes someone can tell me the name I could google to find out more info.  I'm also interested in hearing about any common styles I might have left off.
Latching camera style
The camera has fixed positions in the world where it cam be located and when a transition is made from one to the next, the whole world pauses while the screen moves.  An example of this would be like the camera in the original Zelda game.  There are "screens" and as you move from one screen to the next, the camera shifts to it's new fixed position in effect moving you to the next area.
Balloon camera style
The camera follows your every move.  In most games it lags slightly behind the player's movement as if the camera were attached to a balloon being held by the central character.  When the player stops moving, the balloon floats up, eventually coming to it's resting point directly above the central character's current location.  In some games, it just always stays directly on top, but it's effectively the same mechanic.

These are not the technical names (I googled them and nothing comes up, so I'm pretty sure they are not), but can someone tell me what the technical names are?  Also, are there any major styles of camera movement in 2D games that I have left off?


texts: What is the correct way of implementing a deterministic frame update?

texts:
My goal:

Implement the game update loop so that it's deterministic (i.e. every frame of updation behaves the same when run multiple times with same frame-input, does not depend on processing speed etc.)
Limit the framerate of the game at (maximum) 60fps (can be slower if CPU hangs)

What I don't want to do:

I don't want to use a delta_time to compute position updates, because it violates the goal
Don't want to introduce any additional input-lag that would come with any sort of buffering (for interpolating time between frames etc.)

What I came up with:

I use vsync to guarantee that the game never produces more than 60 fps
I disallow any screen-mode that is not running at 60Hz because the game would run at different speeds
I allow windowed mode only if the current screen-mode is at 60Hz

Is there a better approach that what I'm doing to achieve what I want, perhaps without limiting the supported refresh rates?


texts: Unity new UI - Dynamically change the functions called by GUI elements

texts:
Looking to dynamically change the value in the button OnClick and slider On Value Changed

.

If I had to guess on how this was done, get a reference to the button/gui element. Next get the Button script component and access that list of function calls. However I'm not sure how to modify that list. Anyone have any ideas?

More Details that might help:

The function being called is apart of a custom script component
Using the 'dynamic' variable option for the sliders
Could be used to create dynamic buttons


texts:
I'm creating a lightning geometry shader using hlsl that creates an array of points based on an arbitrary number of generations.
The gist of what I want to accomplish is here:
http://drilian.com/2009/02/25/lightning-bolts/

The problem is the fact that the pseudo-code uses a dynamic array which deletes the current generations line segment and then resizes to add new line segments. I can only use fixed sized arrays in hlsl.

My current code is as stands:

int generations = 4;
int pointsarraysize = pow(2, generations) + 1;
float3 points[pointsarraysize];
points[0] = startpoint;
points[pointsarraysize - 1] = endpoint;

for(int currentgeneration = 0; currentgeneration < genetations; ++currentgeneration)
{
    for(int i = 0; i < pointsarraysize; ++i)
    {
        if (i == pow(2, currentgeneration))
        {

        }
    }
}

So what i've got  creates an array of the size of points I want to end up with and sets the start point and end point.

How do I fill the array so that each iteration over the array creates the points in the right place in the array? I can't simply iterate linearly and calculate points depending on the index position because calculating, for example, the first point in an array with 4 generations requires the start point point[0] and a generation 3 point, point[2].

Is this even the best way to fill the array or am I missing something that could simplify the problem? I want to be able to change the number of generations rather than hard coding a certain amount.


texts: I want to instantiate an object on only the server and one client. This means Network.Instantiate is out of the question and I have to instantiate it manually. Since Network.Instantiate takes a prefab, there must be some way of identifying a prefab over a network( you can't send a reference in an rpc. ) How can I do this? Drag and dropping the prefab from the inspector is also not an option, since the component with this reference is on the server only( the client doesn't have a local reference. )


texts: What are the advantages and disadvantages to using a game engine?

texts: How do I know whether or not to use a game engine? I want to make a relatively complex 2D game for Android. What factors should I weigh to decide whether to find, install and learn a game engine or just do everything manually?


texts: Securing a replay-based leaderboard system (as much as possible)

texts:
A few years ago, I implemented a basic online leaderboard system in one of my games that sent encrypted score data over the wire. The encryption keys were stored in the game client's binary. Of course, the leaderboards got hacked the same day they were released.
I have now released a new game on Steam, and I've worked hard to implement fully-deterministic game logic and a replay system.
The replay system works by simply replaying the user's input that was recorded in a previous playthrough. The fully-deterministic game logic ensures that the replay will work on any machine, independently of the game's FPS.
Now, it is time for me to implement online leaderboards.
My idea is to create a server version of the game executable which receives replay files over the network, replays them on some remote machine, and adds the score to a database if the replay data is valid.
While this prevents cheaters from simply sending a fake score to the server, it opens up many other cheating avenues, including:

Tool assisted creation of replays, either by slowing down the game speed or by manually crafting a replay file after reverse-engineering its format (the game is open-source).

Taking someone else's replay and sending it over the network, changing data regarding who the replay belongs to.

I could somehow encrypt and compress the replay data before sending it over (or saving it on the user's local machine), but since the game is open-source, it would be easy to reverse-engineer the encrypted replay format.
What is a good way of securing a replay-based online leaderboard system?
One possible idea I had is to have the server generate an encryption key / token for a specific user which is only valid for a small amount of time, send it over to the client, and only accept replays that are encrypted with that key. This would prevent users from uploading older replays to the server, but in theory it should work -- am I missing something?


texts:
I was asked by a client to create a pretty simple 3D game that will be embedded on a website, a plain landing page that will contain the game and will be played on mobile devices.
The game itself has no complexity whatsoever, not in the functional aspect and not in the lighting/shaders aspect - the basic functionality is a simple finger swipe in order to "throw" a ball.
I have checked and concluded that opening a webGL game on mobile devices might cause issues and only high-end devices can run the game smoothly.
My question is -
Is there a go-to solution or any solution in which I can develop the game on Unity and build it for webGL in a way that it will be compatible with mobile devices?
Or my only option is to develop the game using plain JS?


texts: Need help starting with a game in Flash/AS3

texts:
I am kinda new to flash/AS3. I have written some stuff and now I now the basics of AS. I want to develop a game in which my character moves. exactly like the way Super Mario moves(the background changes and new obstacles come in the way like and animation with which you can interact by climbing and shooting etc.) There is one big thing that I don't understand is that how to make my  background moving and introduce new obstacles when my character moves forward. Currently my scene is static which means the background is the same and obstacles are also stationary. Can some point me to a tutorial or give me an answer that solves my confusion?
thanks


texts: Is this way of making an XNA game window borderless safe to use for various Windows PCs?

texts:
I have found a way to simply make an XNA 4.0 game's window borderless. Here is the code from the article:

IntPtr hWnd = this.Window.Handle;
var control = System.Windows.Forms.Control.FromHandle( hWnd );
var form = control.FindForm();
form.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
form.WindowState = System.Windows.Forms.FormWindowState.Maximized;

You add it to the Game's constructor and it works perfectly. I tested it on several Windows PCs and it's great: the game runs seemingly in full screen, even if you set the game's resolution lower/higher than your desktop one. The only issue I had with it is the fact that you need to provide positions for XNA's SpriteBatch methods (Draw and DrawString) in desktop resolution, not in game's resolution, while retrieving width/height from GraphicsDevice gives you the latter.

At the same time, DOTA 2 has borderless window option, but the game scales the window down, if your requested in-game resolution is lower than your desktop one. I wonder if they have a good reason for doing this?

I wanted to ask if this approach is safe to use on PC or can it be buggy occasionally? I would especially like to know if it will work with Windows XP as I don't have a pc with this system to test it.


texts:
I am new to Roblox scripting (Lua apparently) and was fiddling with a function that is called when one Part (dubbed the "Sender") is touched by another Part, which is actually a tool with a Part called "Handle" inside of it, and a third Part nested inside that. I have also added an IntValue to the latter to be read upon touching.

The object tree looks like this:

__Apple (Tool)
  L_Handle (Part)
    L_TouchInterest
    L_Value (IntValue)
    L_Apple (Part)
    L_Handle-to-Part Strong Joint

The function is called alright, and the part with the name "Handle" is correctly identified, but I cannot for the world get a hold of the IntValue using the following code:

function onTouch(hit)
    print("Sender touched by "..hit.Name)
    local val = hit:FindFirstChild("IntValue", true)
    if val == not nil then
        print("Found IntValue: "..val.Name)
        if val.Name == "Cash" then
            --Get Money For Apple
            print("Players: "..game.Players.LocalPlayer.Name)
            game.Players.LocalPlayer.leaderstats.Money.value = game.Players.LocalPlayer.leaderstats.Money.value + val.value
        end
    else
        print("IntValue Not Found!")
    end
    hit:Destroy()
end
script.Parent.Touched:connect(onTouch)

In other words: It keeps on logging "IntValue Not Found"!
I have changed the name of the IntValue to "Value" and back to "IntValue" to no avail. I have been adding clones of it to several different layers of the composite object, but no results.

Any help is greatly appreciated!

BTW The object is a Tool, because the player is supposed to be able to pick it up and place it on the "Sender".


texts: Tips for writing 3D Collision detection with opengl

texts:
I would like to any tips/articles/tutorials on how to write collision detection using OpenGL and C++ in 3D mainly just simple box collisions etc but also if there are any advanced resources that would be great to. i also don't wont to use any external library`s if possible.

thanks


texts: Anyone can suggest some Game Frameworks for GNU/Linux?

texts:
So I've been developing a little bit with XNA + C# in Windows, not really much: just some 2D stuff, but I've found that XNA is a really good framework.

I'm a GNU/Linux user, and I'm definitely migrating my desktop to Gentoo Linux (I've been using Arch in my laptop for a while now).

But, of course, I need a C# + XNA alternative... I'm not really an expert in any language, so I can really pick up anything (except, maybe, Functional ones), I prefer C-Like languages like Java or Ruby, I tried Python but found the Whitespace syntax confusing.

I would like to hear some of you'r suggestions, I'm not asking for "the best", but for "some suggestions", so I think this is objective enough.

Probably you're going to suggest C++ + SDL, but I would prefer something more "High Level" like XNA, but I'm open to discuss anything.

So... any ideas ?

Note: I think this questions meets the guidelines for this site, if it doesn't: please not only downvote this question, but comment on what can I do to improve it.
Thanks.

PS: 2D Games, not 3D


texts: How can I access an OpenGl buffer from within a GLSL 330 shader?

texts:
I am currently attempting to create a simulation using OpenGl's GPU acceleration for both the simulation computations and rendering. The rendering portion of my simulation is complete and working, but I still need to create the simulation portion. To do this, I want to use transform feedback, for I am rendering as GL_POINTS and each point needs to be moved in relation to every other point each frame. This matches nicely to a vertex shader and transform feedback abstraction. The issue comes from the fact that my input data (the initial positions of each point) is in a buffer, and each vertex shader invocation in the transform feedback render only has access to that specific entry in my buffer, while I need access to all entries in my buffer. How can I solve this issue?

I can't use compute shaders because I am targeting OpenGl 3.3. I have also considered taking the buffer data, copying it to the CPU, and then back to the GPU in the form of a texture, however this is likely to be incredibly inefficient, especially as I begin scaling up how many points I am working with. This is further exasperated by the fact that textures don't allow me to get pixels at integer coordinates, and passing whole numbers as floating point coordinates is likely to cause floating point error to be sufficiently significant to be a problem, especially with texture filtering (I have thousands of points for now, but that will increase to whatever my GPU can handle once I have it working).


texts:
Sorry if my code looks amateur I just started modding, although I have experience in Java.

I have a tile entity checking every frame if there are entities above it. It works, but then stops after 1 tick. Here is the code I am using.

import java.util.List;

import net.minecraft.entity.Entity;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.ITickable;
import net.minecraft.util.math.AxisAlignedBB;

public class TileEntityConveyor extends TileEntity implements ITickable {

    public static float speed = 1f;

    @Override
    public void update() {
        if (this.worldObj.isRemote)
            return;
        double x = this.pos.getX();
        double y = this.pos.getY();
        double z = this.pos.getZ();

        AxisAlignedBB collsion = new AxisAlignedBB(x, y, z, x + 1, y + 2, z + 1);

        List<Entity> list = this.worldObj.getEntitiesWithinAABB(Entity.class, collsion);

        for (Entity entity : list) {
            entity.motionX += speed;
            //          this.
        }
    }

}


texts:
I'm building a html5 canvas game and I need a way to get my sprite to face the mouse cursor. I have the X and Y co-ordinates for the sprite, and also the X and Y co-ordinates of the pointer. All I'm stuck with is the math involved to make the sprite face the pointer. It's all in a 2D world, so I can't imagine it'll be too complicated, but I have very little experience with this stuff.

Also any helpful links to articles/blog posts about this sort of thing would be awesome (2D game programming in general, not specifically Javascript).

To add, i should note that I need an angle in degrees that will point me towards the cursor using its X and Y position.

How can i know the co-ordinates of the cursor and where do i put all of this stuff ?


texts:
I need some advice on how to design the Entity module in my game, how to apply the MVC pattern and generally how the Entity should interact with its controller and its representation.

First some details about the game: it's a 2D action-platformer, it's data-driven (or rather, I'd like it to be data-driven — it isn't yet) and the Entities should be scriptable (I'll be using Python).

I'm still at the very beginning of the development and I have some general ideas about how the Entity module should work, but I get stuck on the details. Here's roughly what I have up until now:

class Entity
{
  private:
    // The representation holds the actual animation and sounds that
    // are used to render the entity. The representation can read the
    // Entity's state but it cannot alter it.
    EntityRepresentation* representation_;

    // The controller handles events and changes the Entity's state
    // based on these events.
    EntityController* controller_;

    // Here's some of Entity's attributes
    struct Vector{ float x, y; } position_;
    float directionRadians_;
    float speed_;

  public:
    void handleEvent(const Event& e) {
        controller_->handleEvent(e, this); // It's obvious what it does :)

        // The representation needs to handle events so it can change the
        // current animation, queue up a sound for playing, etc. In my
        // current setup it doesn't yet need to take 'this' as a parameter.
        representation_->handleEvent(e);
    }

    void update(unsigned long timePassed) {
        position_.x += speed_ * timePassed * std::cos(directionRadians_);
        position_.y += speed_ * timePassed * std::sin(directionRadians_);
        // .. And any other updates I might need to do...
    }

    void render(DrawingContext* context, unsigned long timePassed) {
        representation_->render(context, timePassed, position_.x, position_.y);
    }
};

There are a few things I think could be problematic in this setup. For one, if you look at the Entity::handleEvent() function you will see that the Entity forwards the event to the controller as well as to the representation. The controller uses the event to alter the state of the Entity; the representation however uses it to alter its own state (to use some other animation, to decide whether it should play a sound, etc.).

This means the representation has a state of its own which is characteristic to this Entity only. Do you think it's bad that each representation can only be used for one Entity? (Note: this does not mean that in case there are two entities using the same sprite, that sprite is loaded twice in memory: the sprite itself is a common resource.)

Another thing I'm having problems with the deciding how to organize the actual entity data on disk. Where should the bounding box info be read from: the animation or somewhere separate? should there be a single animation file for each character? should scripts be separate from the data or should everything related to one type of entity be stored in a single folder (scripts and animation and sounds)?

tl;dr Can you give some some general advice on how the Entity should interact with its controller and its representation (i.e. sprites and sounds). Also, do you have any advice on how the data itself should be organized on the hard-drive?


texts: Find closest point on NavMesh if current target unreachable

texts:
I have a mock environment set up with a cube that has a specified "Not Walkable" layer.
I'm using NavMeshAgent and NavMeshPath to set destinations of the player.
The way I'm setting paths is by ray-casting points on the terrain by mouse clicking.

I'm having trouble figuring out a way to fix if I click on the cube that has a "Not Walkable" layer, the player just runs into the cube and tries to reach that point.

I've read about the FindClosestEdge function in unity but I don't think that's exactly what I'm looking for.

So basically I need the target location to change to the nearest point next to the cube when I click on the cube.

Any ideas?


texts: Networking library compatible C++ and Java

texts:
There is any networking library like eNet compatible with Java and C++?

'm trying to find a way to communicate an Android game in Java with a C + + server, but I prefer to use a network library instead raw sockets.

I've found a java-enet, but I don't know if it's a mature project or compatible with eNet C version.


texts: One big spritesheet vs many smaller spritesheets?

texts:
I have my 2D character animations which are stored in spritesheets. I have individual sprite sheet for every animation. For example, if my character have animations for idle, run and jump, I have 3 different spritesheets.

Is it good way for managing 2D animations or it's better to store all animations in one big spritesheet? I noticed that many old games animations are stored in one big spritesheet - is it the best way?


texts: Activating particle system after 2 triggers on enter

texts:
I would like that

particle system must play indefinetely at some position after two triggers on collision are triggered on enter.
When game starts, particle system is deactivated.

I have make this script where I can attach particle system into prefab and I have set spawnpoint position.

1) Is it possible to activate particle system differently (without Instantiate) ?

2) How to make that two triggers on enter activate particle system? One trigger is not enough.

using System.Collections;

using System.Collections.Generic;
using UnityEngine;

using System.Collections;

using System.Collections.Generic;
using UnityEngine;

public class spawn_object : MonoBehaviour {

public Transform spawnpoint;
public GameObject prefab;

public int i=1;
// Use this for initialization

while (if <=2)
{
void OnTriggerEnter () {

    Instantiate (prefab, spawnpoint.position, spawnpoint.rotation);
            }
    i++;
}

}


texts:
I'm new to game development (but not new to software development). As a personal/learning project, I'm designing an overhead-view 2D online RTS game (static, no scrolling). The first cut will pretty much only require simple sprites, with typical menus, text, and buttons.

Most of the game logic will happen server-side, with unit positions and other vitals sent to the browser at about 30 fps. The client won't do much, aside from the display and UI.
The server stuff is easy for me, but I need a little guidance on the browser display.

Having read up on several new browser technologies/HTML5 libraries, I'm getting more overwhelmed by the options, not less! I don't necessarily need the absolute best tool; what I want is a technology that will make it easy to implement a simple sprite-based game, and do a decent job of it.

I know JS itself well enough, but not any of the fancy graphics/game libraries. I know Flash/AS3 (doing what I want in Flash would be easy enough, but the mobile browser support concerns me--should I steer clear if I want iOS support?). I have the entire Adobe suite (subscription), if that helps. I'm not averse to learning a new language/API/tool, of course, but the more I can put what I know to good use, the better.

So, my question (yes, there is one in here somewhere!) is, what are my (best) options today for implementing the in-browser (display) part of said 2D online browser-based game, based on the above goals and stated skillset/available tools? Since it may be difficult to be completely objective, please do include a little rationale on why you believe your answer is the right tool for this job. I'm not asking for a doctoral thesis, here, just a paragraph or two. :-)


texts: Gamemaker: Get from which children action is called

texts:
I've got 3 Children in 1 Parent which has "Left pressed" action. I just want to know from which child this action is called.

I try object_index but obviously it returns Parent index.

Thanks in advance.

EDIT #1: put in Left pressed

with(other) { var id = object_index; }

will return object child which perform this event


texts: Unity 3D - Materials are Stretching and Tiling doesn't Help

texts:
I am a programming student working with Unity 3D, version 2018.4.6f1 for this class. I wanted to add some materials to my wall, however, this results in a rather ugly result, because my walls are of different sizes.

This also happens with actual textures.

However, editing their "tiling" as suggested does not result in something pretty, because the sizes of the objects. (In the shown example, both tilings are x: 3 and y:4.) I can't seem to edit the individual tiling on each object, either.

How can I fix this, and make everything look nice? I obviously don't want to create a gazillion of the same texture/material just so I can tile it differently for each object.


texts: How to sync animations of 2 different characters in Unity 3D?

texts:
I am working on an endless running 3d game. I have 2 characters. One of them is a small kid and another one is a security guard. Both characters and animations are exported as separate FBXs.

The scene is something similar to the situation in Subway Surfer, where the cop picks up the character. See first few seconds - https://www.youtube.com/watch?v=FdxgHMh0QEc

For this we animated both the characters in a single file in 3DS Max. In this file one character has to pick other character by his leg.

Now how should I proceed so that both the animations play in sync when shown in the game.
What would be the best approach to sync different characters in Unity when using different files ?
Or should I export a single file containing both the characters and animations and use it just for this scene?

Any help would be really appreciated. Thanks in advance.


texts: I am pretty new to game development and graphic stuff. I find that compute shader is somehow more powerful and flexible than Pixel Shader for almost everything I need so far. But Pixel/Fragment shader should exists for a reason, could anybody let me know when I'd better to use Pixel shader rather than a compute one? Thank you very much.


texts:
I am trying to create a very simple client-server based physics game, using box2d library. A simple football game.
Obviously, the server runs only the box2d world.
My question is:
is it correct to state that the client should run not only the needed rendered simulation but another box2d world as well?

I ask this because I know that the client should receive state information of the elements that have a changing state. And this information is received in packets every few ticks. And between every packet received, there's a time gap where I need to run the world like "nobody did nothing", and then correct the world state if somebody did something after I received the next packet.
That is why I need to run the box2d world in the client as well, but I feel it's kinda awkward and assymetrical.

Is this right? Is box2d prepared for this?


texts: How can I draw a rectangle with a color gradient?

texts:
I'm trying to implement the below picture in my code but doesn't work. It only shows red color on all sides. I'm using line renderer and color gradient. Kindly check my code.

void Start()
{
lineGeneratorPrefab = new GameObject();

DrawLine();
}

private void DrawLine()
{
GameObject myLine = new GameObject();
myLine.transform.position = start;
myLine.AddComponent<LineRenderer>();
lr = myLine.GetComponent<LineRenderer>();
lr.material = new Material(Shader.Find("Sprites/Default"));
lr.positionCount = 4;
lr.SetPosition(0, new Vector3(-2, 0, 0));
lr.SetPosition(1, new Vector3(2, 0, 0));
lr.SetPosition(2, new Vector3(2, -2, 0));
lr.SetPosition(3, new Vector3(-2, -2, 0));
lr.loop = true;

Gradient gradient = new Gradient();
gradient.SetKeys(
    new GradientColorKey[]
    {
        new GradientColorKey(Color.red, 0.25f),
        new GradientColorKey(Color.blue, 0.25f),
        new GradientColorKey(Color.green, 0.25f),
        new GradientColorKey(Color.yellow, 0.25f)
    },
        new GradientAlphaKey[] { new GradientAlphaKey(1.0f, 0.0f) }
    );
lr.colorGradient = gradient;

}


texts:
I'm creating some rectangles surrounding my sprites for my player and bullet class to detect collisions with the overlaps method in Intersector class of LibGDX.

I have a question:

When I instantiate Player and Bullet, I create a bounding box around the sprite using sprite.getBoundingRectangle() which returns a Rectangle object. I update the movement of these somewhere else in the main class.

When I update the movement of the bullet/player sprite, do I also need to update the position of the bounding box surrounding the bullet/player sprite? Or since the bounding Rectangle surrounds the sprite, will the box automatically move with the sprite?

Thanks


texts: Why does glGetUniformLocation report some of my uniform locations as -1?

texts:
I have been writing GLSL shaders for over a year but this is the first time I have run into this problem. I am on the iOS platform - if that matters.

In a vertex shader I have this:

uniform mediump mat4 projectionViewModelMatrix;

In a fragment shader I have been using for months I have the following uniforms:

uniform int channels;
uniform sampler2D hero;

Nothing to write home about. I added three additional uniforms to the fragment shader:

uniform int heroChannels;
uniform int heroWidth;
uniform int heroHeight;

Using

glGetUniformLocation

I tried to grab the location of all my uniforms. This is when my own personal hell began. This is the result:

uniform heroChannels location -1
uniform channels location 4
uniform hero location 5
uniform heroHeight location -1
uniform projectionViewModelMatrix location 0
uniform heroWidth location -1

Huh? Why are the recently added uniforms not given a valid location by the GL Gods?


texts:
I have a model of an SMG with arms exported from Blender and set to generic rig in unity import settings. I was creating an animation for this model in Unity Animation tab, it included changes in position and rotation of the individual parts like magazine and left arm and gun itself. Then when I was satisfied with how the animation worked (I saw it by pressing the play button IN THE ANIMATION TAB). My problem is that when I click play IN THE GAME TAB there is no rotation and some movement, only some parts move (but not rotate). Does anyone know what could be my problem? I am not sure what screenshots to post so tell me what you need to see and I'll add some.
Thanks in advance.


texts: How to make a text box where text "types" smoothly

texts:
I want to create a textbox that behaves like most textboxes seen in other games where the text appears gradually. So far this has been my attempt at it but unfortunately, the text appears very unevenly and slow even when changing the letter pause to an insanely low amount.

public float letterPause = 0.1f;

IEnumerator TypeText()
{
    //number of char typed per loop
    int len = 3;
    for (int i = 0; i < text.Length; i += len)
    {

        if (i + len > text.Length)
        {
            ibubbletext.text += text.Substring(i, text.Length - i);
        }

        else
        {
            ibubbletext.text += text.Substring(i, len);
        }
        yield return new WaitForSeconds(letterPause);
    }
}


texts: HLSL texture not reading from register S1

texts:
I made a simple post processing shader, that draws scanlines. This all works perfectly. I wanted to make it a bit more interesting by applying a shadowmask instead so I wanted to pass a texture to the shader. From my understanding the Spritebatch sets Texture Register(S0), so I set my shadowmask texture to Texture Register(s1).

When applying the shader is seems that both S0 and S1 contain the texture I plan to draw. I have tried to set parameters in different ways- without succes. How can I pass the Texture?

My HLSL code:

sampler ScreenTextureSampler: register (s0); // This is the texture that SpriteBatch will try to set before drawing
sampler ShadowSampler: register (s1); // This is set in GraphicsDevice.Textures[1];

int colorlines = 2;
int shadowlines = 1;

//------------------------ PIXEL SHADER ----------------------------------------

float4 PixelShaderFunction(float4 pos : SV_POSITION, float4 color1 : COLOR0, float2 texCoord : TEXCOORD0) : SV_TARGET0
{
    float4 color = tex2D(ScreenTextureSampler, texCoord.xy);
    float4 maskcolor = tex2D(ShadowSampler, texCoord.xy);

    float ypos = pos.y;
    float scanline = (ypos) % (colorlines + shadowlines);
    float intensity = scanline < colorlines ? 1 : 0.20f;

    //comment out one of these two return statements...
    return maskcolor*intensity; //note this return has the exact same result
    return color*intensity;     //as this one! even though the samplers point at different registers.

}

technique Postprocessing
{
    pass Pass1
    {
        PixelShader = compile ps_4_0  PixelShaderFunction();
    }
}

This shader is loaded in an Effect called Assets.GameArt.PostProcessor. I have a shadowmask Texture2D in Assets.GameArt.shadowTexture.

My C#, Monogame code looks like this:

        gd.SetRenderTarget(null);

        sb.Begin(SpriteSortMode.BackToFront, BlendState.AlphaBlend, SamplerState.PointClamp, DepthStencilState.None, RasterizerState.CullNone, Assets.GameArt.PostProcessor, Resolution.getTransformationMatrix());

        gd.Textures[1] = Assets.GameArt.shadowTexture;

        sb.Draw(_gameRenderTarget, Vector2.Zero, _camera.Viewport, Color.White);

        sb.End();

gd points to the GraphicsDevice and sbis the spriteBatch. I first render my scene to a _gameRenderTarget.

Why isn't the Texture passed via the S1 register (or: why do the texture samplers both return the same result?)


texts: When serializing a class, can its fields take their defaults from the Unity editor?

texts:
Can I have a custom serialized class whereby I set a value in the editor and that value persists into runtime, as happens with serialized monobehaviour fields?
Currently it sets itself to 0 or a default hard coded from within the class.
I noticed that using a struct actually works but using a struct breaks the events used in my actual use case (included below).
Example code:
public class Class1 : MonoBehaviour
{
    // this variable can be set in the editor and persist into run time
    [SerializeField]
    private float testVar1;

    // this variable can not
    [SerializeField]
    private Class2 class2;

    private void Start()
    {
        class2 = new Class2();
    }
}

[Serializable]
public class Class2
{
    [SerializeField]
    private float testVar2;
}

My use case:
[Serializable]
public class EditorFloat
{
    [SerializeField]
    public float value;
    public EventProperty<float> eventProperty;

    public EditorFloat(EventProperty<float> eventProperty)
    {

        this.eventProperty = eventProperty;
        Object.FindObjectOfType<CentralParams>().OnUiChange += Update;
        this.eventProperty.OnChanged += UpdateEditor;
    }
    public void Update()
    {
        eventProperty.Value = value;
    }
    public void UpdateEditor(float valueFromEventProperty)
    {
        value = valueFromEventProperty;
    }
}

Thanks!


texts:
I have made a vertex shader and fragment shader and kind of know how they work, and I know that you specify what index you want your vertices to be in inside the shader program. So if the vertex was at index 0, does each vertex take up 1 index? If each one took up an index, than how many indices would a matrix 4x4 take up? Sorry if thats confusing but I'm just starting and I don't really know how the indices within the shader works. So:

#version 140
in vec3 position; //This could be located at index 0
in mat4 randomMatrix; //If this came right after position, what index is it located at??
void main() {
    gl_Position = vec4(position.x * 0.5, position.y * 0.5, position.z * 1, 1);
}

Tell me if I have this all wrong.


texts: Long running calculation on background thread

texts:
In my Cocos2D game for iOS I have a relatively long running calculation that happens at a fairly regular interval (every 1-2 seconds). I'd like to run the calculation on a background thread so the main thread can keep the animation smooth.

The calculation is done on a grid. Average grid size is about 100x100 where each cell stores an integer. Should I copy this grid when I pass it to the background thread? Or can I pass a reference and just make sure I don't write to the grid from the main thread before the background thread is done?

Copying seems a bit wasteful but passing a reference seems risky. So I thought I'd ask.


texts: What are the implications of releasing without a trademark?

texts:
I've been working on a video game for almost a year now and with release looming I'm starting to panic cause I don't have a trademark (but I do have a company).

I really don't want to have to push release back a year to wait for the trademark process... Can I get around this and just release (safely) somehow?


texts: "Binding" script functions to C++ functions

texts:
I appreciate the answer to this question might be a little too broad for SE, but hopefully someone can point me in the right direction.

I'm developing a small scripting language for use in my game engine, and naturally in order to do really useful things with it, it needs to hook into actual C++ functions in my game.

For example, say I have an Inventory class, with a public function, checkItem(itemID) that is designed to check whether a certain item is in the current inventory or not.

I'd love to be able to define a scripting function that calls the built-in checkItem function for its value during some script's lifetime. Is there a standard / simple-to-implement procedure for doing this? Something that has a similar effect to LuaBind, for example?

I can of course add instructions to my scripting VM that call the functions internally, but this will make the VM a bit of a mess and require implementing separate operations for each function I wish to call.


texts: Is it possible to store a 3d unit length vector with only 2 components, for example as coordinates on a unit sphere? It seems possible but I have never seen anyone do this. Would this be at all practical?


texts: How Do I 'Reset' my Render Texture When I Stop a Video Player?

texts: I have a Unity VideoPlayer where I use a render texture with an audio source to play the video. VideoPlayer.Stop pauses the video and resets the time to 0. I want to reset the VideoPlayer back to its default after I stop the video player. I searched the Scripting API but I did not see anything obvious on how to do this. How do I do this?


texts: Jump Script Component For Character Controller

texts:
I'm trying to implement a jump method into my FPSInput script. I know how to make this work for a Rigidbody, but how can I accomplish this with my Character Controller? Does CharacterController have a method comparable to AddForce?

First Person Movement Input:

public class FPSInput : MonoBehaviour {
    public float speed = 6.0f;
    public float gravity = -9.8f;

    private CharacterController _charController;

    void Start() {
        _charController = GetComponent<CharacterController>();
    }

    void Update() {
        float deltaX = Input.GetAxis("Horizontal") * speed;
        float deltaZ = Input.GetAxis("Vertical") * speed;
        Vector3 movement = new Vector3(deltaX, 0, deltaZ);
        movement = Vector3.ClampMagnitude(movement, speed);

        movement.y = gravity;

        movement *= Time.deltaTime;
        movement = transform.TransformDirection(movement);
        _charController.Move(movement);
    }
}

Works for Rigidbody only:

public class Jump : MonoBehaviour {

    public Vector3 jumpVector;

    // Update is called once per frame
    void Update() {
        if (Input.GetKeyDown(KeyCode.Space)) {
            GetComponent<Rigidbody>().AddForce(jumpVector, ForceMode.VelocityChange);
            }
        }
}


texts: Game Maker: How do I make a score display move with the view?

texts:
I have drawn everything needed to the screen including a HUD for the score, but I have my room set to follow my player: When the camera follows the player, the score HUD stays doesn't scroll with him!

How do I make the score display follow along with the player also?


texts: Sound emmiters with panning and volume in 2D

texts: How can I create sound emmiters that pan and change volume based on distance from the player in a 2D game?


texts:
I am currently trying to implement the Bullet physics into my game project. However, when i add some rigid bodies to the scene, i occasionally get an error in btDbvtBroadphase.cpp at the line
  if(proxy->stage==STAGECOUNT) (line 294).

If i then inspect the proxy pointer, it points to 0x0. If I go back to the function btCollisionWorld::updateSingleAabb(btCollisionObject * colObj) on the call stack, and inspect the member m_broadphaseHandle, it is non-zero, which is being passed as first parameter to btDbvtBroadphase::setAabb(btBroadphaseProxy* absproxy, const btVector3& aabbMin, const btVector3& aabbMax, btDispatcher* __ formal).
In this method it is being cast into a btDbvtProxy pointer and stored in proxy. What I don't get here is, why proxy becomes 0x0, even though a valid pointer is being passed to the function.

The call stack looks like this:

MyProject.exe!btDbvtBroadphase::setAabb(btBroadphaseProxy * absproxy, const btVector3 & aabbMin, const btVector3 & aabbMax, btDispatcher * __formal) Line 294   C++
MyProject.exe!btCollisionWorld::updateSingleAabb(btCollisionObject * colObj) Line 171   C++
MyProject.exe!btCollisionWorld::updateAabbs() Line 204  C++
MyProject.exe!btCollisionWorld::performDiscreteCollisionDetection() Line 220    C++
MyProject.exe!btDiscreteDynamicsWorld::internalSingleStepSimulation(float timeStep) Line 492    C++
MyProject.exe!btDiscreteDynamicsWorld::stepSimulation(float timeStep, int maxSubSteps, float fixedTimeStep) Line 452    C++

The initialization of bullet looks like this:

broadphase = new btDbvtBroadphase();
collisionConfiguration = new btDefaultCollisionConfiguration();
dispatcher = new btCollisionDispatcher(collisionConfiguration);
solver = new btSequentialImpulseConstraintSolver;

world = new btDiscreteDynamicsWorld(dispatcher, broadphase, solver, collisionConfiguration);
world->setGravity(btVector3(0.0f, -10.0f, 0.0f));

I create RigidBodies procedurally and this is, how I add them:

bp.mesh = new btTriangleMesh(true, false);

for (int i = 0; i < bp.numFaces; ++i)
{
    btVector3 a(vertices[indices[i * 3 + 0]].position.x, vertices[indices[i * 3 + 0]].position.y, vertices[indices[i * 3 + 0]].position.z);
    btVector3 b(vertices[indices[i * 3 + 1]].position.x, vertices[indices[i * 3 + 1]].position.y, vertices[indices[i * 3 + 1]].position.z);
    btVector3 c(vertices[indices[i * 3 + 2]].position.x, vertices[indices[i * 3 + 2]].position.y, vertices[indices[i * 3 + 2]].position.z);
    bp.mesh->addTriangle(a, b, c);
}

btMotionState* ms = new btDefaultMotionState;
btBvhTriangleMeshShape* shape = new btBvhTriangleMeshShape(bp.mesh, true);

sect->rigidBody = new btRigidBody(0.0f, ms, shape);

btWorld->addRigidBody(sect->rigidBody, 64, 128);

My question now is, why proxy occasionally points to 0x0, even though it should be a valid pointer? I downloaded and successfully compiled bullet-2.82-r2704 with VS2012 and changed the project settings from /MT(d) to /MD(d), if this does matter.

Edit: I may also mention that the rigid bodies are added in a different thread, than the thread in which I initialize and simulate the bullet physics. Can this cause any problems?


texts:
Sure there's something I'm missing about wrap/repeat textures in D3D 9.  I've tried setting the sampler in the shader, i.e. :

sampler DiffuseSampler =
sampler_state
{
    Texture = <DiffuseMap>;

    MipFilter = NONE;
    MinFilter = POINT;
    MagFilter = POINT;

    AddressU = WRAP;    // Repeat on X
    AddressV = WRAP;    // Repeat on Y.
};

, and I've also tried doing it in code before I render the object:

device->SetSamplerState(D3DVERTEXTEXTURESAMPLER0, D3DSAMP_ADDRESSU, D3DTADDRESS_WRAP);
device->SetSamplerState(D3DVERTEXTEXTURESAMPLER0, D3DSAMP_ADDRESSV, D3DTADDRESS_WRAP);
device->SetSamplerState(D3DVERTEXTEXTURESAMPLER0, D3DSAMP_MAGFILTER, D3DTEXF_POINT);
device->SetSamplerState(D3DVERTEXTEXTURESAMPLER0, D3DSAMP_MINFILTER, D3DTEXF_POINT);
device->SetSamplerState(D3DVERTEXTEXTURESAMPLER0, D3DSAMP_MIPFILTER, D3DTEXF_NONE);

I thought there might be something screwy with my texture coordinates too, so I hard coded them to be 0.0, 0.0 on the left and 2.0, 2.0 bottom right.  I expected x 2 repeat but got a similar result to the screenshot, with the texture top left and then what looks like clamp across the rest of the image.

What mistake have I made here? (Note that the screenshot isn't the 0.0, 0.0 -> 2.0, 2.0 experiment I did, it's the general case I get as I'm panning my image around).


texts:
p0 ------- p1 ------- p2

I am successfully slerping between 2 points (p0-p1; p1-p2). But the transition between two slerped angles (p1_in-p1_out) do not match, and it looks jarring

Video of how it looks:

green squares are points, the position and angle between each are interpolated.

The issue is most visible at second 6.00

https://gfycat.com/unhealthygraveduckling

I tried hermite splines, although it reduces the effect, it's still visible.

I tried converting Catmull-Rom to use with quaternions by just adding the 4th index to the vector functions. This works perfectly except on some occasions, where some are interpolated from the wrong (long) "way", causing the view to flip between those points. I tried aligning, did not help.

Other questions on SO related to slerp don't ask this question, and I could not get any usable answers from some questions on 4 point slerps.

Is this a common issue, am I overseeing something?

Thanks


texts:
I've made a vector which is used by a universally accessible namespace called 'BULLET_HANDLER'. This vector stores and updates all bullets that are produced from the 'shootBullet' function. The problem I'm facing is that after a while of firing bullets, the vector does not draw or update the bullets and does not push back anymore bullets. It also doesn't crash the game and the game continues normally but none of the objects can fire bullets.

Here is the code for the Bullet Handler:

#include "BULLET_HANDLER.h"

static vector<Bullet*> BULLET_ARRAY;

void BULLET_HANDLER::shootBullet(Bullet *BULLET) {
  BULLET_ARRAY.push_back(BULLET);
}

void BULLET_HANDLER::Update() {

  for (unsigned int i = 0; i < BULLET_ARRAY.size(); i++) {
    if (BULLET_ARRAY.size() > 0) {
      if (
        BULLET_ARRAY[i]->getX() <= 0 - BULLET_ARRAY[i]->getW() ||
        BULLET_ARRAY[i]->getX() >= WINDOW_WIDTH) {

        BULLET_ARRAY.erase(BULLET_ARRAY.begin() + i);
      }
    }

    BULLET_ARRAY[i]->Update();
  }
}

void BULLET_HANDLER::Draw(SDL_Surface *Window_Surface) {

  for (unsigned int i = 0; i < BULLET_ARRAY.size(); i++) {
    BULLET_ARRAY[i]->Draw(Window_Surface);
  }
}

void BULLET_HANDLER::clearBulletArray() {
  BULLET_ARRAY.clear();
}


texts: Projectile Aim Prediction with Acceleration

texts:
I'm trying to solve the classic shoot moving object problem but with acceleration attached to that changes it from a quadratic to quartic formula but my math skills are not this good sadly as i prefer to speak in code and not formulas.

i found this https://wiki.beyondunreal.com/Legacy:Projectile_Aiming. i ported it and it's almost what i'm looking for but missing control over the acceleration as its only made for gravity or no gravity and even this i got working only with tricks and modifying it without knowing what i'm doing is getting me only that far.

I made myself a Prototype Interface for the minimum of what i'm trying to get out of it

public class PredictionResult {
    public bool IsInRange; // can we even hit the target?
    public Vector3[] ShotVelocity; // should be up to 4 possible values
    public float[] ShotImpactTime; // how long each shot takes to arrive at the predicted target
    public Vector3[] ShotImpactLocation; // somewhat redundant yet still useful if available
}
// only really the delta between start and target matter but its up to the function
// same for startVel and targetVel where startVel is the shooters speed that gets added to the bullet
// the bullet and target can have different accelerations (standing on ground => no gravity or bullet is not affect by gravity)
public PredictionResult ShootAtTarget(Vector3 start, Vector3 target, Vector3 startVel, Vector3 targetVel, Vector3 bulletAccel, Vector3 targetAccel, float bulletSpeed);

any help solving this would be great


texts: Determine user mouse selection of 3D Object for multiple viewports

texts:
I am currently working on setting up some world objects for my level editor and am running into a bit of a snag. When I get the hit location from the mouse raycast, I would like to determine what part of the object that the user has hit. I am looking for something that would work for each viewport in my map editor.

I would like to use hit detection change the color of an object when the user mouses over it. For instance, if the user mouses over the x axis (red arrow) it would turn from red to white. It doesn’t have to be pixel perfect but I would like to find a single solution that would work in all viewports.

I was thinking that after I get the hit location, I could transform the hit location to match the inverse of the rotation of the camera and perform the checks from there. I'm skeptical that solution will work though.


texts:
I'm designing a board game (Settler of Catan) in which you should be able to use resources to build constructions like roads, settlements, etc.

I have a View in which i draw my map on, also a button Build. If a player wants to build something, he/she should click it and should be able to choose which tile he/she wants to build it on.

The thing is i'm wondering if i should start a new Activity just for this Build -Action or should i implement a methode that runs a while- loop until the user has chosen in which tile he/she wants to build the thing on.

In my mind, a while-loop has never been a good way because the programm has to check the condition almost always -> maybe a problem of performance.

I'm thankful for any suggestion to solve this problem.


texts: I've watched some tutorials on java game development and when they start using spritesheets all they do is get a subimage out of the spritesheet and create a new BufferedImage out of that. Does java do some sort of batching behind the scene when drawing the images like some engines and libraries do? Is it even possible to batch in java, and if so how would I go about doing it?


texts: How are Objects rendered or updated, when there's a Pool class?

texts:
I have a State (Title State for example), that has the ResourcePool (getImage();getSound(); etc.)
and a list of the GameObjects.

How do GameObjects get access to the Resources in the Pool they need?

Should the GameObjects have a reference to their resources at construction time or possibly even the pool itself?

The GameObjects render/update themselves.


texts: Move Camera Freely Around Object While Looking at It

texts: I've got a 3D model loaded (a planet) and I have a camera that I want to allow the user to move freely around it. I have no problem getting the camera to orbit the planet around either the x or y axis. My problem is when I try to move the camera on a different axis I have no idea how to go about doing it. I am using OpenGL on Android with the libGDX library. I want the camera to orbit the planet in the direction that the user swipes their finger on the screen.


texts:
I have yet another question regarding SDL2.

I have some drawSprite & drawBackround & drawText functions, all draw to the screen. They do this by creating a new surface, turning it into a new texture, rendering the texture, then destroying/freeing everything.

This worked fine until I wanted to put it in a very fast loop. There was a slight delay (or something) which caused images on the screen to flicker. (It would draw a background, draw sprites, draw text, then loop. So this caused the sprites to flicker.)

I looked up the issue, and found that you shouldn't create and destroy a texture every single frame, AKA allocate and deallocate memory every single frame. So, I created some a global texture and surface variables, with the intent to re-assign these variables every time I called any of the drawing functions, and then destroy them when the program closed. (Reduce, Reuse, Recycle!)

This did not work. My memory required by my program ballooned upward into the gigabytes, which made it totally unresponsive. Through some trial and error, I found that I STILL had to run DestroyTexture and FreeSurface functions at the end of each drawing function. I don't understand why this is, since I'm reusing the variables.

Anyways, once I added those back in I've found that my program is working but is MUCH SLOWER in rendering than before!!! Why is this??? What did I do wrong? (again)


texts: How about fitting into gaming industry with Design and Development mindset and seeking for a masters degree?

texts:
Might be the question is a bit weird but that's what I'm focused on and want to discuss about obtaining a masters degree to fulfill my dreams to work as both designer and developer.

I work as a programmer with 5 years of experience and I code in C, C++, C#. Back home I design Application UX, Logo, Banners, Website graphics, Write small software for personal needs or friends and yes I like to play games.

Now, holding a bachelor degree in Computer science and professional experience I want to opt for a Masters degree abroad(probably in Europe) with focused subject(may be Game design/development). Now my problem is that I do not like to do a formal Computer science masters as it would be a traditional process of learning computer systems. As well as I don't like mathematics in dept, having said that I do use calculation and business logic a lot in my programs but I'm not very much fond of them. So basically I'm a design creativity guy with developer mindset. I developed quite a few windows applications on my own and some of them are live on Softpedia.

So I like to pursue my future with the mix of both. Is there any way for me to fit into game industry? If not what would be better for me rather than continue only programming job profile?


texts: Can problems arise in client-server network games due to the permanent sending of messages?

texts:
I'm my Client-Server-based game I'm using the following stack:

libGDX (Engine)
Ashley (ECS)
KryoNet (Networking)
Box2D (Physics)

Server =========> Client
I've got a Box2DSyncSendingSystem on server-side and a Box2DSyncReceivingSystem on client-side.
This will create a list of all body-values from every entities with a BodyComponent in its update()-method and till than send this list via a BodyUpdateMsg to the clients. The client therefore receiving it and adjust all the values to the local bodies.
Client =========> Server
On the other Hand the clients will keep sending their Input values to the server via a InputSendingSystem so the server can adjust the velocities.

The problem that concerns me is that these steps happen every time the update methods are run. So several times a second. Somehow it doesn't seem very well resolved to me.
Sure: You could only send body updates if values have changed. But even if you follow this approach, you could not do without the repeated and permanent sending of the input update messages from the client to the server.
It is also clear to me that there are topics where client-side prediction should compensate for the high latencies, but the problem with the input updates is still there.
I don't want to implement a rocket science like high-end solution (the project is not big enough for that), but rather to implement a good and classic approach, which is typical for network games.
My previous approach may also not be wrong and absolutely common.
Thanks in advance!


texts: How do I set the gravity of a plane world

texts:
As you can see in the image, the character is set to move on a ground plane, however that causes an issue with Box2d's gravitational pull.
The player can go sideways, upwards and downwards on the plane.
Is there any way I can use gravity in this case?


texts: Rect transform stretch of a child object is set to 0 after instantiation

texts:
I have the following hierarchy of my prefab:
-PopupParent
--Popup
---ScreenDim

They all have Rect Transform set to Stretch. Anchor mins are set to 0 and Anchor maxes to 1. Left, top, right and bottom are set to 0. When I pull this prefab to a Canvas manually, all works as expected.
When I instantiate the prefab the problem I am encountering is, that the PopupParent is stretched as expected, to the full screen, but all its children are not.
PopupParent looks like this:

Children Popup and ScreenDim look like this:

The instantiation I am doing using the Spawn Prefab Node in the Event editor provided by the ORK Framework. I am Mounting the PopupParent to my UICanvas.
It could be, that the issue is caused by some Framework settings, but it might very well be related to how Unity works in general. I am not sure and can't find a way to figure it out.
SOLUTION: I got ORK support to reply and solve the issue for me: http://forum.orkframework.com/discussion/6465/spawning-a-prefab-with-a-stretch-property#latest
TL;DR: Regular mounting and UI mounting works slightly different.


texts:
I built a teleporter that changes a players position and rotation.
He is instantly teleported back. Why?

I'm using the standard FPS Controller.


texts: How many and which axes to use for 3D OBB collision with SAT

texts:
I've been implementing the SAT based on:

Dynamic Collision Detection using Oriented Bounding Boxes [PDF]

On page 7, in the table, it refers the 15 axis to test so we can find a collision, but with just Ax, Ay and Az, I'm already getting collisions.

Why do i need to test all the other cases? Is there any situation where just Ax, Ay and Az are not enough?


texts: Which university shall I choose in UK? ( game programming )

texts:
I'm starting my undergraduate studies soon, but as I'm not from UK, I completly don't have idea what university should I choose.

Do you know any good game programming universities?

Is it good idea to make computer science as undergraduate studies and game-programming as postgraduate one? I'm thankfull for all your replies, as they help me alot.


texts: Transparent diffuse fails to render from all viewing angles

texts:
I'm rendering this chunk as a Unity mesh and I have just one material (with alpha) which is applied over all the mesh.

Everything in the chunk is automatically generated at runtime, so it's not possible to prepare anything in advance, even the materials.

Here the model is rendering correctly (from a specific point of view which works):

The problem is this:

And here you see that it works if the mesh isn't rendering on itself.

When the material is applied, if you watch on the transparent section you will see it semi-transparent (which is the correct and expected behaviour), or you will see it just in part, because the transparency gets overlapped by the parts of the mesh which are behind the transparent part.

In some cases it even disappears or make anything that is on it disappear.

Does anyone know a good shader that can fix this problem and that is a diffuse?
I tried to modify zTest in the shader, but nothing changes, or the render gets even worse.

Here are the two shaders:

This is the one the material uses

Shader "Custom/Diffuse" {
Properties {
    _Color ("Main Color", Color) = (1,1,1,1)
    _MainTex ("Base (RGB) Trans (A)", 2D) = "white" {}
}

SubShader {
    Tags {"Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent"}
    LOD 50

CGPROGRAM
#pragma surface surf Lambert alpha

sampler2D _MainTex;
fixed4 _Color;

struct Input {
    float2 uv_MainTex;
};

void surf (Input IN, inout SurfaceOutput o) {
    fixed4 c = tex2D(_MainTex, IN.uv_MainTex) * _Color;
    o.Albedo = c.rgb;
    o.Alpha = c.a;
}
ENDCG
}

Fallback "Custom/VertexLit"
}

And here is the second, which the first refers to.

Shader "Custom/VertexLit" {
Properties {
    _Color ("Main Color", Color) = (1,1,1,1)
    _SpecColor ("Spec Color", Color) = (1,1,1,0)
    _Emission ("Emissive Color", Color) = (0,0,0,0)
    _Shininess ("Shininess", Range (0.1, 1)) = 0.7
    _MainTex ("Base (RGB) Trans (A)", 2D) = "white" {}
}

SubShader {
    Tags {"Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent"}
    LOD 100

    Alphatest Greater 0
    ZWrite Off
    ZTest Always
    Blend SrcAlpha OneMinusSrcAlpha
    ColorMask RGB

    // Non-lightmapped
    Pass {
        Tags { "LightMode" = "Vertex" }
        Material {
            Diffuse [_Color]
            Ambient [_Color]
            Shininess [_Shininess]
            Specular [_SpecColor]
            Emission [_Emission]
        }
        Lighting On
        SeparateSpecular On
        SetTexture [_MainTex] {
            Combine texture * primary DOUBLE, texture * primary
        }
    }

    // Lightmapped, encoded as dLDR
    Pass {
        Tags { "LightMode" = "VertexLM" }

        BindChannels {
            Bind "Vertex", vertex
            Bind "normal", normal
            Bind "texcoord1", texcoord0 // lightmap uses 2nd uv
            Bind "texcoord", texcoord1 // main uses 1st uv
        }
        SetTexture [unity_Lightmap] {
            matrix [unity_LightmapMatrix]
            constantColor [_Color]
            combine texture * constant
        }
        SetTexture [_MainTex] {
            combine texture * previous DOUBLE, texture * primary
        }
    }

    // Lightmapped, encoded as RGBM
    Pass {
        Tags { "LightMode" = "VertexLMRGBM" }

        BindChannels {
            Bind "Vertex", vertex
            Bind "normal", normal
            Bind "texcoord1", texcoord0 // lightmap uses 2nd uv
            Bind "texcoord1", texcoord1 // unused
            Bind "texcoord", texcoord2 // main uses 1st uv
        }

        SetTexture [unity_Lightmap] {
            matrix [unity_LightmapMatrix]
            combine texture * texture alpha DOUBLE
        }
        SetTexture [unity_Lightmap] {
            constantColor [_Color]
            combine previous * constant
        }
        SetTexture [_MainTex] {
            combine texture * previous QUAD, texture * primary
        }
    }
}

}


texts:
I'm trying to develop a fast-paced multiplayer game.

Now I'm using UDP as a transport-layer protocol to communicate between clients and server. But what if I want to implement a chat? Should I send chat messages via UDP as well (with re-sending and other TCP-like stuff) or should I use another TCP socket for such purposes?

Which one is the best practice?


texts: Triangle Strips and Tangent Space Normal Mapping

texts:
Short:
Do triangle strips and Tangent Space Normal mapping go together?

According to quite a lot of tutorials on bump mapping, it seems common practice to derive tangent space matrices in a vertex program and transform the light direction vector(s) to tangent space and then pass them on to a fragment program.
However, if one was using triangle strips or index buffers, it is a given that the vertex buffer contains vertices that sit at border edges and would thus require more than one normal to derive tangent space matrices to interpolate between in fragment programs.

Is there any reasonable way to not have duplicate vertices in your buffer and still use tangent space normal mapping?

Which one do you think is better: Having normal and tangent encoded in the assets and just optimize the geometry handling to alleviate the cost of duplicate vertices or using triangle strips and computing normals/tangents completely at run time?

Thinking about it, the more reasonable answer seems to be the first one, but why might my professor still be fussing about triangle strips when it seems so obvious?


texts:
Many projects don't think about localization until the game is done. Then localization is done as a hack, and it's obvious that it was added on later. Some specific areas of concern:

Text strings (obviously)
Audio clips such as music and/or narratives
Text rendered on textures (e.g. a label on a crate)
Text rendered in frames in pre-rendered movies
Fonts/Character sets for different languages
Etc.

What are some good ways to prepare for these challenges in the initial development stages, so you can make it easier without incurring too much cost up front?


texts:
I'm making a Bubble Shooter game in Unity. I came to the point where I can hit another bubble and it destroys all of its neighbors.

Now I'm trying to use recursion to destroy all of its neighbors neighbors and it causes a stack overflow.

private List<Bubble> FindAllRecursiveNeighbors(Vector2Int originPosition)
{
    List<Bubble> allNeighbors = FindNeighbors(originPosition);
    List<Bubble> result = new List<Bubble>();

    foreach (Bubble bubble in allNeighbors)
    {
        if (result.Contains(bubble)) { continue; }
        result.Add(bubble);
    }

    // Recursion starts here.
    foreach (Bubble bubble in result)
    {
        List<Bubble> neighbors = FindAllRecursiveNeighbors(FindPositionOfBubble(bubble));
        foreach (Bubble neighbor in neighbors)
        {
            if (result.Contains(neighbor)) { continue; }
            result.Add(neighbor);
        }
    }
    return result;
}


texts:
all i've a little trouble understanding some concepts while making game please give your suggestions on my questions.

I have a animated sprite image this i want to move this image according to given path. I can get path from

    Path path = new Path();
    Point s = new Point(150, 5);
    Point cp1 = new Point(140, 125);
    Point cp2 = new Point(145, 150);
    Point e = new Point(200, 250);
    path.moveTo(s.x, s.y);
    path.cubicTo(cp1.x, cp1.y, cp2.x, cp2.y, e.x, e.y);

    canvas.drawPath(path, paint);

these points are hard coded and give different results on different screen.

Q1. How can i make path which is similar in all screen size?

Q2. How can i move my animated sprite image according to given path with the image has it's head according to path?


texts: What scoring system should I use in my game?

texts:
I'm trying to determine how good a player is getting throughout his gameplay and hopefully adapt the level of the game to his expertise.
Currently I have a scoring system. For example, if the player collects tokens he gets scores, if he's hit by a monster he looses score etc.

I'd like to log this score based on time(time = the amount of time passed since player started playing), and compare previous plays to the current gameplay score at any given time. If i see that the player's score is much higher than usual I'll adapt the gameplay to challenge him, and the other way around of course.

As to the question. I'm trying to understand what module would be best for:

Building the previous score per time values. For each gameplay I'll have to update the previous score per time with the new score with some mean. I'm just not sure which one I should use? (should I keep separate values of last two game plays and all the rest, and then give more weight for last games when calculating the means?)
How should I detect significants? What would be the best way to detect player is playing much better or worse?

Also, if anyone could refer me to good tutorials, essays, etc. I will be very greatful.

Thanks


texts: Why is the alpha value of a Sprite in LibGdx 0.99607843 and not 1?

texts:
I'm developing a game in LibGDX and one of my problems is related to the alpha value of a Sprite object.

If I create a new Sprite sprite object then sprite.getColor().a is equal to 0.99607843 and not 1. If I try to set sprite.setAlpha(1) it still sets it to 0.99607843. I also tried doing sprite.getColor().a = 1; but it still didn't work. My question is why is that? Is this just a limitation in LibGDX or am I doing something wrong?

(I put an issue on the official lib gdx github page. As of now the issue has been solved just because it was a duplicate of another issue, from what I get this problem is because of lib gdx, but the alpha still gets corrected on the shader side.)


texts: RPC events with client side interpolation

texts:
I've implemented client side interpolation, where a specified delay is put on each client. This allows them to interpolate between positions and rotations. Unfortunately, this means every thing else must be delayed, otherwise events ( like a particle effect on a collision ) will happen ahead of time( according to the interpolated data. )

Should I delay everything along with the interpolated data, or do I have the wrong idea about client side interpolation? I haven't seen a single mention of this problem anywhere, which makes me think I'm missing something.


texts: unity : How to change the default behaviour of the touchpad/trackpad in laptop?

texts:
I'm using unity on my laptop. Normally, i can customize my touchpad in most of 3d app but in unity i can't find a way to do it ? is it possible to customize it at user level without hard coding it ?
I just want the touchpad to behave like most app : 2 fingers pinch to zoom, 2 fingers drag to rotate view etc.


texts: How to interpolate server updates on the client for multiplayer?

texts:
I am implementing client-side prediction and an authoritative server multiplayer architecture. I am following along with the series of articles from http://www.gabrielgambetta.com/entity-interpolation.html

I am at a point of confusion and have a few questions.

Within my client game loop I have a sequence of actions that update the local state.

applyLocalUpdates(state, loopTime)
reconcileLastRemoteUpdate(state, loopTime)

applyLocalUpdates

This updates all the entities positions based on their local physics and game logic simulation.
reconcileLastRemoteUpdate

I am in the process of implementing this and is the point of confusion. My initial naive attempt takes the last received server state and sets each local entities position to that last remote one.

This produces a choppy update effect. When each server update comes in the entities jump to match that last server position.

This is where I am trying to add interpolation...

I have interpolation methods like vec3.lerp(a,b,t) and quat.lerp(a,b,t) which I use to update the position vector and rotation quaternion.

My unknown points are:

Which values do I pass for a and b in the interpolation?

Is this the most recent local state and the last server state?
What value do I pass in for t in the interpolation?

This I'm highly confused. Is this the difference of elapsed time between the last 2 server states?

Is it the difference of elapsed time between the last local update and the last server update?

Additionally, should I swap the order of execution between applyLocalUpdates and reconcileLastRemoteUpdate ?


texts: Unable to list target platforms. Please make sure the android sdk path is correct. (Error)

texts:
When i am trying to build an apk from unity. Than its show me some error something like this :-

CommandInvokationFailure: Unable to list target platforms. Please make sure the android sdk path is correct.
E:/DEWA/msgs/Kunal/android-sdk-windows-1.6_r1\tools\bin\avdmanager.bat list target -c

stderr[

]
stdout[

ERROR: JAVA_HOME is set to an invalid directory: C:\Program Files\Java\jdk1.8.0_121\lib\tools.jar;C:\Program Files\Java\jre1.8.0_141\lib\rt.jar;

Please set the JAVA_HOME variable in your environment to match the
location of your Java installation.
]
exit code: 1
UnityEditor.Android.Command.WaitForProgramToRun (UnityEditor.Utils.Program p, UnityEditor.Android.WaitingForProcessToExit waitingForProcessToExit, System.String errorMsg)
UnityEditor.Android.Command.Run (System.Diagnostics.ProcessStartInfo psi, UnityEditor.Android.WaitingForProcessToExit waitingForProcessToExit, System.String errorMsg)
UnityEditor.Android.AndroidSDKTools.RunAndroidSdkTool (System.String toolName, System.String arguments, Boolean updateCommand, UnityEditor.Android.WaitingForProcessToExit waitingForProcessToExit, System.String errorMsg)
UnityEditor.Android.AndroidSDKTools.ListTargetPlatforms (UnityEditor.Android.WaitingForProcessToExit waitingForProcessToExit)
UnityEditor.Android.AndroidSDKTools.GetTopAndroidPlatformAvailable (UnityEditor.Android.WaitingForProcessToExit waitingForProcessToExit)
UnityEditor.Android.PostProcessor.Tasks.CheckAndroidSDK+SDKPlatformDetector.GetVersion (UnityEditor.Android.AndroidSDKTools sdkTools)
UnityEditor.Android.PostProcessor.Tasks.CheckAndroidSDK+SDKComponentDetector.Detect (UnityEditor.Android.AndroidSDKTools sdkTools, System.Version minVersion, UnityEditor.Android.PostProcessor.ProgressHandler onProgress)
UnityEditor.Android.PostProcessor.Tasks.CheckAndroidSDK.EnsureSDKComponentVersion (System.Version minVersion, UnityEditor.Android.PostProcessor.Tasks.SDKComponentDetector detector)
UnityEditor.Android.PostProcessor.Tasks.CheckAndroidSDK.EnsureSDKComponentVersion (Int32 minVersion, UnityEditor.Android.PostProcessor.Tasks.SDKComponentDetector detector)
UnityEditor.Android.PostProcessor.Tasks.CheckAndroidSDK.Execute (UnityEditor.Android.PostProcessor.PostProcessorContext context)
UnityEditor.Android.PostProcessor.PostProcessRunner.RunAllTasks (UnityEditor.Android.PostProcessor.PostProcessorContext context)
UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr)

Build completed with a result of 'Failed'
UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr)

UnityEditor.BuildPlayerWindow+BuildMethodException: 2 errors
  at UnityEditor.BuildPlayerWindow+DefaultBuildMethods.BuildPlayer (BuildPlayerOptions options) [0x0020e] in C:\buildslave\unity\build\Editor\Mono\BuildPlayerWindowBuildMethods.cs:181
  at UnityEditor.BuildPlayerWindow.CallBuildMethods (Boolean askForBuildLocation, BuildOptions defaultBuildOptions) [0x00065] in C:\buildslave\unity\build\Editor\Mono\BuildPlayerWindowBuildMethods.cs:88
UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr)

Error building Player: CommandInvokationFailure: Unable to list target platforms. Please make sure the android sdk path is correct.
E:/DEWA/msgs/Kunal/android-sdk-windows-1.6_r1\tools\bin\avdmanager.bat list target -c

stderr[

]
stdout[

ERROR: JAVA_HOME is set to an invalid directory: C:\Program Files\Java\jdk1.8.0_121\lib\tools.jar;C:\Program Files\Java\jre1.8.0_141\lib\rt.jar;

Please set the JAVA_HOME variable in your environment to match the
location of your Java installation.
]
exit code: 1


texts: Most efficient 3d depth sorting for isometric 3d in AS3?

texts:
I am not using the built in 3d MovieClips, and I am storing the 3d location my way.

I have read a few different articles on sorting depths, but most of them seem in efficient.

I had a really efficient way to do it in AS2, but it was really hacky, and I am guessing there are more efficient ways that do not rely on possibly unreliable hacks.

What is the most efficient way to sort display depths using AS3 with Z depths I already have?


texts: How to update the value of all owners of shared_ptr?

texts:
I’m writing a render, there is a class that shaders should store, something like a shader manager. These shaders are stored as

std :: map <std :: string, std :: shared_ptr <BaseShader>> cache;

BaseShader is an abstract class (there are virtual methods).

Other classes want to own shaders, and request them accordingly by name. That is, they each have a copy of the smart pointer. After the change, the shaders need to be rebooted from the disk. Accordingly, new is done and written by name in the cache, the problem is that clients do not see this change. How to make sure that the reset for the smart pointer is not made, and the updated object was copied to the same address that it stores?


texts:
I've got a problem with drawing 2D texture in xna 4.0.
My program generates terrain texture:

The problem is in rough surface of my texture (dark-blue) that is generated by-pixel. Is there any method to smooth my texture without scaling it? (SamplerState didn't help me)

A lot of thanks in advance.


texts: Error modify bools from script1 iin script2 then get bools value frrom script2!

texts:
I have a GameObject called "emptyobject" with a FullOrFree component attached, containing several public boolean variables:

using UnityEngine;

public class FullOrFree : MonoBehaviour {

    public bool a1, a2, a3, a4, a5, b1, b2, b3, b4, b5;

    void Start()
    {
        a1 = false;
        a2 = false;
        a3 = false;
        a4 = false;
        a5 = false;
        b1 = false;
        b2 = false;
        b3 = false;
        b4 = false;
        b5 = false;
    }
}

Next I have a script on a car prefab, that tries to modify these bools:

script1 script1;

void Start() {
    GameObject.Find("emptyobject").GetComponent<script1>().Bools();
}

//... later, in some method?

    if (!b1)
    {
        print("---R1--Ok-03");
        go = "B1";
        can = true;
        script1.b1 = true; //like that
    }

But I always get this error:

  NullReferenceException: Object reference not set to an instance of an object

The game is about parking. The game will Instantiate this prefab car, and it needs to park in one of six lines. Each line has 2 spots (a1,b1), and this code tries to select the spot to park in.


texts:
I am trying to port a HLSL shader to GLSL. I'm just not quite sure how to convert this line:

  outA += Input.Color.a * tex2D(s, Input.TexCoord.xy + float2(-4.0 * pxSz.x * blurSize,0)).a * 0.05;

It's mostly the Tex2D I'm having trouble with. In GLSL, it seems to work differently.

I'm porting a horizontal blur

 texture al_tex;
   sampler2D s = sampler_state {
      texture = <al_tex>;
   };

   int tWidth;
   int tHeight;
   float blurSize = 5.0;
   float4 ps_main(VS_OUTPUT Input) : COLOR0
   {
      float2 pxSz = float2(1.0 / tWidth,1.0 / tHeight);
      float4 outC = 0;
      float outA = 0;
      outA += Input.Color.a * tex2D(s, Input.TexCoord.xy + float2(-4.0 * pxSz.x * blurSize,0)).a * 0.05;
      outA += Input.Color.a * tex2D(s, Input.TexCoord.xy + float2(-3.0 * pxSz.x * blurSize,0)).a * 0.09;
      outA += Input.Color.a * tex2D(s, Input.TexCoord.xy + float2(-2.0 * pxSz.x * blurSize,0)).a * 0.12;
      outA += Input.Color.a * tex2D(s, Input.TexCoord.xy + float2(-pxSz.x * blurSize,0)).a * 0.15;
      outA += Input.Color.a * tex2D(s, Input.TexCoord.xy + float2(0,0)).a * 0.16;
      outA += Input.Color.a * tex2D(s, Input.TexCoord.xy + float2(pxSz.x * blurSize,0)).a * 0.15;
      outA += Input.Color.a * tex2D(s, Input.TexCoord.xy + float2(2.0 * pxSz.x * blurSize,0)).a * 0.12;
      outA += Input.Color.a * tex2D(s, Input.TexCoord.xy + float2(3.0 * pxSz.x * blurSize,0)).a * 0.09;
      outA += Input.Color.a * tex2D(s, Input.TexCoord.xy + float2(4.0 * pxSz.x * blurSize,0)).a * 0.05;

     outC.a = outA;

      return outC;
   }

Thanks


texts: How to convert point coordinate when taking a snapshot?

texts:
Can anyone explain me please how to convert point from Screen-coordinate system to Texture 2D?
The screen size say for example 700x500 and Texture2D must be of size 1024x768. I am getting points from scene, convert them with camera.WorldToScreen and then multiply by ratio, which doesn't work correctly for some reason.
Here is my code:

//PROCESSING POINTS
cam_pts[i] = detector.WorldToScreenPoint(pts[i]);
cam_pts[i].y = Screen.height - cam_pts[i].y;
cam_pts[i].x = cam_pts[i].x * (ImageWidth/(float)Screen.width);
cam_pts[i].y = cam_pts[i].y * (ImageHeight/(float)Screen.height);

//SAVING CAPTURE SCREEN
RenderTexture rt = new RenderTexture(ImageWidth, ImageHeight, 24);
detector.targetTexture = rt;
Texture2D screenShot = new Texture2D(ImageWidth, ImageHeight, TextureFormat.RGB24, false);
detector.Render();
RenderTexture.active = rt;
screenShot.ReadPixels(new Rect(0, 0, ImageWidth, ImageHeight), 0, 0);
detector.targetTexture = null;
RenderTexture.active = null;
Destroy(rt);
byte[] bytes = screenShot.EncodeToPNG();
string filename = string.Format("Screenshot_{0}.png", counter);
System.IO.File.WriteAllBytes(filename, bytes);

The red points must be at the corners of the pallet.
I am new in Unity and C# and will be thankful if someone explains me how to do it right.


texts:
I am UK based and am looking to set up my own game studio - essentially, just myself working from home, looking to build casual game apps. I want to ask you guys what steps or process i need to go through and do to make this happen, specifically the legal side of things. Will be great to hear from those who have been through this themselves! Need to register with HRMC as self employed is the only thing i know i have to do but what else?:

Do i need to register/trademark my own company/studio name? If so, where do i do this and does it cost money? Or can i just simply start using a name as is?
Do i need to also do this for any games/apps IP i make? Or is copyright automatically assumed?
I gather acting as sole trader is more appropriate at this stage? At what point, if ever, should i consider moving to an actual limited company setup?
Is it wise to open a new bank account solely for this business?

I think my plan was simply to:
1. Find a suitable domain name and create website based on my company name - assuming available and different enough from similar competitor names
2. Register as self employed with HRMC
3. Sell my game on app store

And thats it! Is this ok or do i need consider other stuff as well such as the questions above?

Thank you for reading and any advice you have!


texts: UE4 - storing complex actors in Game Instance

texts:
I want to make a game where I can hold tools in my hand and inventory. Obviously I want to pass them between levels and maybe even game sessions. Question is, how would I do that?

With simple variables like amount of money or HP, all I do is store a variable in the Game Instance. But what about, for example, a tool that has more data, like the class type, durability, maybe value? Even worse, whole array of them?

The way I use that in game is, there's an actor representing the tool. But even if I store array of those in the game instance, the actors get destroyed while changing level and the array just points empty memory. I could just spawn new ones by using the class type - but that is not enough for me.

My idea is to create something... maybe a struct, that would hold the information and then recreate the inventory item actors according to the data in the struct.

My questions:
What are other ways to do it?
and
Is there something fundamentally wrong with the way I'm storing the items in my inventory now?


texts: windows phone 7 apps marketplace paid to free

texts:
I have question about paid and free + ad-based apps/games in wp7 marketplace, can I publish my app as paid version initially and later(after a month or so) can i publish the same app/game as free + ad based version? Is there any such rule/policy in wp7 marketplace.
I could not find proper answer on the net not lucky enough. And i hope this is not off topic question.  - Thanks


texts: How to save the Mesh from an Interactive Cloth at runtime in Unity?

texts:
At the start of a scene I have GameObject called 'sheet' positioned above a 'ball' GameObject. The sheet has an Interactive Cloth component on it and a Cloth Renderer. The Mesh for the Interactive  Cloth component is a plane with a high number of vertices. At runtime the sheet drops over the ball and creates the shape I want. If I disable the Interactive Cloth component at this point the sheet mesh stay exactly as I want it but I cannot pull it out as a Prefab.

Does anyone know a way to get a copy of that shape?

For example by reading the mesh from the Interactive Cloth at runtime and then using that to change the mesh back how I want it without the Interactive Cloth component.

Any help would be greatly appreciated.


texts: score and high score system for multiple levels

texts:
I'm trying to create a scoring system for a game with multiple levels. For this I'm using the binary formatter instead of playerprefs (I read online that playerprefs are not that secure). I have created the system but whats happening is that the score is not resetting to 0 when I load a new level. If in one level the score was 10 and I start some other level, the score in this level starts from 10 instead of 0. This is the code I have so far:

public class ScoreIncrease : MonoBehaviour
{
  public Text scoreTxt;
  public int score;

void Start()
{
    LoadScore();
}

void Update()
{
    if (Input.GetKeyDown(KeyCode.Space))
    {
        Save();
    }
}

public void Save()
{
    score++;
    scoreTxt.text = "Score" + score;
    BinaryFormatter bf = new BinaryFormatter();
    FileStream file = File.Open(Application.persistentDataPath + "/scoreContainer.dat", FileMode.Create);

    ScoreContainer scoreContainer = new ScoreContainer();
    scoreContainer.score = score;
    bf.Serialize(file, scoreContainer);
    file.Close();
}

public void LoadScore()
{
    if(File.Exists(Application.persistentDataPath + "/scoreContainer.dat"))
    {
        BinaryFormatter bf = new BinaryFormatter();
        FileStream file = File.Open(Application.persistentDataPath + "/scoreContainer.dat", FileMode.Open);
        ScoreContainer scoreContainer = (ScoreContainer)bf.Deserialize(file);
        file.Close();
        score = scoreContainer.score;
        scoreTxt.text = "Score" + score;
    }
  }
}

[Serializable]
public class ScoreContainer
  {
    public int score;
  }

How can I change this so that each level has a separate highscore and all levels have a start score of 0?


texts: how to calculate intersection time and place of multiple moving arcs

texts:
I have rocks orbiting moons, moons orbiting planets, planets orbiting suns, and suns orbiting black holes, and the current system could have many many layers of orbitage.

the position of any object is a function of time and relative to the object it orbits.
(so far so good).

now I want to know for a given 2 objects(A,B), a start time and a speed, how can I work out the when and where to go. I can work out where A and B is given a time.
so i just need.

1: direction to travel in from A to B(remember B is moving(not in a straight line))
2: Time to get to b in a straight line.

travel must be in a straight line with the shortest possible distance.

as an extension to this question, how will i know if its better to wait, EG is it faster to stay on object A and wait for a hour when the objects may be closer, than to set off from A to B at the start.

Cheers, it hurt my brain.


texts: How can I reset the mouse axes when respawning a player?

texts:
I am making a simple parkour game in which the camera will follow the mouse based on the mouse input axis * the sensitivity. This works great, but when I want to reset my character to the start I cant figure out how to reset the mouse axis to zero, thus preventing me from resetting the camera rotation. I have tried Input.ResetInputAxes();, but that seems to only reset the buttons.
using System.Collections;
using System;
using System.Collections.Generic;
using UnityEngine;
public class Movement : MonoBehaviour
{

    public CharacterController characterController;
    public Transform Player, camera;
    public Camera cam;
    public float XSensitivity, YSensitivity;
    public bool grounded, jumping;
    public float forwardSpeed, horizontalSpeed, jumpPower, gravity, sprintModifier;

    [HideInInspector] public float sideSpeed, lastPlayerPosX, lastPlayerPosZ, jumpSpeed, verticalRotation, horizontalRotation;

    private float isSprinting = 1;

    void Update()
    {
        //This is where I get the axes
        float mouseX = Input.GetAxis("Mouse X"), mouseY = Input.GetAxis("Mouse Y");

        //This is how I rotate the player and camera
        verticalRotation += -mouseY * YSensitivity;
        Player.transform.localRotation = Quaternion.Euler(0, horizontalRotation, 0);
        horizontalRotation += mouseX * XSensitivity;
        cam.transform.localRotation = Quaternion.Euler(verticalRotation, horizontalRotation, 0);

        if (Input.GetMouseButtonDown(0))
        {
            Cursor.lockState = CursorLockMode.Locked;
        }

        float horizontal = Input.GetAxis("Horizontal"), forward = Input.GetAxis("Vertical");

        grounded = characterController.isGrounded;

        if (grounded)
        {
            if (Input.GetKey("left shift"))
            {
                isSprinting = sprintModifier;
            }
            if (Input.GetKey("left shift") == false)
            {
                isSprinting = 1f;
            }
            jumping = false;
            jumpSpeed = 0;
            sideSpeed = .75f;
        }
        else
            jumpSpeed -= (gravity * 25) * Time.deltaTime;

        if (Input.GetKey("space"))
        {
            sideSpeed = .25f;
        }
        if (Input.GetAxisRaw("Jump") != 0 && !jumping)
        {
            jumping = true;
            jumpSpeed = jumpPower;
        }

        lastPlayerPosX = Player.transform.position.x;

        lastPlayerPosZ = Player.transform.position.z;

        Vector3 motion = new Vector3(horizontal * horizontalSpeed * sideSpeed, jumpSpeed, forward * forwardSpeed * isSprinting);
        characterController.Move((Player.transform.rotation * motion) * Time.deltaTime);
    }

    void OnTriggerEnter(Collider col)
    {
        if (col.gameObject.name == "deathbarrier")
        {
            //Resets player to starting position
            Player.transform.position = new Vector3(20.5f, -2, -22.5f);
            //Is supposed to reset all inputs (including mouse)
            Input.ResetInputAxes();
            //Sets camera rotation to 0, but only for one frame before the stored mouse axes change it
            camera.transform.rotation = Quaternion.Euler(0, 0, 0);
        }
    }
}

Thanks for any tips!