texts: Is there a penalty to using render targets versus textures?

texts:
I figured that the best way to ship 2D art for multiple resolutions is to instruct my artist to create the fullscreen background images sized for the highest resolution and then scale them down during the loading stage.

To scale them, during load, I setup a render target sized to the current resolution, SpriteBatch.Draw the assets scaled to the current resolution and then use that render target throughout the game. The render target serves as a SpriteSheet throughout the game. I only do this once (in LoadContent) and not every frame.

My question is whether or not there is a memory/performance penalty for using render targets instead of whatever the ContentManager would've set the textures as. Is there a meaningful way to measure this? Or is there a better way of doing this altogether?


texts: Why there is no isGrounded and Move properties for the CharacterController?

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

[RequireComponent(typeof(CharacterController))]

public class SC_FPSController : MonoBehaviour
{
    public float walkingSpeed = 7.5f;
    public float runningSpeed = 11.5f;
    public float jumpSpeed = 8.0f;
    public float gravity = 20.0f;
    public Camera playerCamera;
    public float lookSpeed = 2.0f;
    public float lookXLimit = 45.0f;

    CharacterController characterController;
    Vector3 moveDirection = Vector3.zero;
    float rotationX = 0;

    [HideInInspector]
    public bool canMove = true;

    void Start()
    {
        characterController = GetComponent<CharacterController>();

        // Lock cursor
        Cursor.lockState = CursorLockMode.Locked;
        Cursor.visible = false;
    }

    void Update()
    {
        // We are grounded, so recalculate move direction based on axes
        Vector3 forward = transform.TransformDirection(Vector3.forward);
        Vector3 right = transform.TransformDirection(Vector3.right);
        // Press Left Shift to run
        bool isRunning = Input.GetKey(KeyCode.LeftShift);
        float curSpeedX = canMove ? (isRunning ? runningSpeed : walkingSpeed) * Input.GetAxis("Vertical") : 0;
        float curSpeedY = canMove ? (isRunning ? runningSpeed : walkingSpeed) * Input.GetAxis("Horizontal") : 0;
        float movementDirectionY = moveDirection.y;
        moveDirection = (forward * curSpeedX) + (right * curSpeedY);

        if (Input.GetButton("Jump") && canMove && characterController.isGrounded)
        {
            moveDirection.y = jumpSpeed;
        }
        else
        {
            moveDirection.y = movementDirectionY;
        }

        // Apply gravity. Gravity is multiplied by deltaTime twice (once here, and once below
        // when the moveDirection is multiplied by deltaTime). This is because gravity should be applied
        // as an acceleration (ms^-2)
        if (!characterController.isGrounded)
        {
            moveDirection.y -= gravity * Time.deltaTime;
        }

        // Move the controller
        characterController.Move(moveDirection * Time.deltaTime);

        // Player and Camera rotation
        if (canMove)
        {
            rotationX += -Input.GetAxis("Mouse Y") * lookSpeed;
            rotationX = Mathf.Clamp(rotationX, -lookXLimit, lookXLimit);
            playerCamera.transform.localRotation = Quaternion.Euler(rotationX, 0, 0);
            transform.rotation *= Quaternion.Euler(0, Input.GetAxis("Mouse X") * lookSpeed, 0);
        }
    }
}

On both I'm getting the same error :'CharacterController' does not contain a definition for 'isGrounded' and no accessible extension method 'isGrounded' accepting a first argument of type 'CharacterController' could be found (are you missing a using directive or an assembly reference?)


texts: Possible to use StateMachineBehaviour with Blend Trees?

texts:
One of the touted benefits of the StateMachineBehaviours is adding a sound hook to an animation state. That sounds great! Unfortunately, I'm not sure how I could do this when a blend tree is involved. I can put a script at the top level of the state containing the blend tree, but how would I go about getting more information so I can figure out what sound to play? Does it even make sense here?

Basically I have a blend between an idle animation and a walk. I'd like to start playing an idle sound when the idle animation starts playing and then crossfade the sound over to a walk as the animation blends over to walk.

Doable?


texts: Applying velocity to parent that ignores children's mass not working

texts:
I am making a VR data visualisation app in Unity and I have a parent with many children (just some primitive cubes) that I can toss around the scene by just setting the parent's rigidbody to the same velocity as my tracked VR controller.
Rigidbody rb = GetComponent<Rigidbody>();
Vector3 controllerVelocity = Player.instance.rightHand.GetTrackedObjectVelocity(); // how I ref the controller velocity in SteamVR
rb.velocity = controllerVelocity * 2f; // the 2f is just to speed up the velocity

The above code works fine, but the problem is I think the scale of the children objects, which can be adjusted by the player, is affecting the velocity the parent moves at. Or maybe just when the children are very large...the controller velocity is comparatively too slow? Basically I need this to not be the case; I want the parent's rigidbody to move at roughly the same velocity no matter the children's scales/masses.
So to achieve that I thought to use Rigidbody.AddForce but it doesn't seem to be making any difference i.e. larger children are still moving slower. Here is what I have so far:
Rigidbody rb = GetComponent<Rigidbody>();
Vector3 controllerVelocity = Player.instance.rightHand.GetTrackedObjectVelocity();
rb.AddForce(controllerVelocity  * 2f, ForceMode.VelocityChange);

I also tried ForceMode.Acceleration but then nothing moved at all? Am I using AddForce incorrectly? Or do I just need a scaling multiplier based on the size of the children? Any help is welcome.


texts: RGB values from image into a one dimension array in c#

texts:
I was wondering if there is a was a way to read rgb values from an image into a one dimensional array in C#. If it doesnt make sense, in java I would do something like this.

int[] pixels;
BufferedImage image = getClass().getResourceAsStream("asdfghjkl.png");

int w = image.getWidth();
int h = image.getHeight();

pixels = new int[w * h];
image.getRGB(0, 0, w, h, pixels, 0, w) ;

So any help would be great, or if you can point me in the right direction, that'd be great


texts: What is some good examples about creating 2D fluids?

texts: Anyone have any good examples, tutorials, or snippets to share that preferably in C# or C/C++?


texts:
I am trying to draw different textures of balloons and I want them to appear in different times about half second between each one, and move in the world. first balloons are rendered but after about half second the other balloons are rendered next to the previous ones, not in the initial place: this is code:

private Ballons ballons;
    private Ballons ballons2;
    private Ballons ballons3;
    private Ballons ballons4;

    private Texture background;
    public Celebration(Fruits game, float level)
    {
        this.game=game;
        this.level=level;
        gamecam=new OrthographicCamera();
        gameport=new StretchViewport(820/Fruits.PPM,580/Fruits.PPM,gamecam);
        stage=new Stage(gameport,((Fruits) game).batch);
        background=new Texture("Wining.jpg");
        gamecam.position.set(gameport.getWorldWidth()/2f,gameport.getWorldHeight()/2f,0);
        temp=0;
        counter=400;
        world=new World(new Vector2(0,0.5f),true);
        b2dr=new Box2DDebugRenderer();
        ballons=new Ballons(world,this,1,140);
        ballons4=new Ballons(world,this,2,290);
        ballons3=new Ballons(world,this,3,480);
        ballons2=new Ballons(world,this,4,650);

    }

    @Override
    public void show() {

    }
    public void handleinput(float dt)
    {
        if(Gdx.input.isTouched())
            game.setScreen(new GlobalWorld(game, 1));
    }
    public void update(float dt)
    {
        handleinput(dt);
        world.step(1 /60f, 6, 2);
        //player.update(dt);
        gamecam.update();
//        renderer.setView(gamecam);
        ballons.update(dt);
        ballons2.update(dt);
        ballons3.update(dt);
        ballons4.update(dt);
    }

    @Override
    public void render(float delta) {
        float level;
        update(delta);
        Gdx.gl.glClearColor(1, 1, 1, 1);
        Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
        counter--;
        b2dr.render(world, gamecam.combined);
        game.batch.setProjectionMatrix(gamecam.combined);

        game.batch.begin();

        game.batch.draw(background, 0, 0, gameport.getWorldWidth(), gameport.getWorldHeight());
        if (counter < 200) {
            ballons.draw(game.batch);
            ballons2.draw(game.batch);

        }
        if (counter < 100) {
            ballons3.draw(game.batch);
            ballons4.draw(game.batch);

        }
        game.batch.end();

    }

    @Override
    public void resize(int width, int height) {
        gameport.update(width, height);

    }

}


texts: How do I get parabolic movement in Unity using Rigidbody2d?

texts:
EDIT: It was the Animator after all. Apply Root Motion basically nullifies any physics based work.

I "know" this answer but I can't figure out what can possibly be wrong. My code is in FixedUpdate(). My Rigidbody2D has a Gravity Scale of 4 and a Mass of 1. For whatever reason a Gravity Scale of 1 just isn't strong enough to keep it from floating away. In the pictures below the little cubes should be marking each frame.

Using the below code I get a jagged leap movement. The object shoots upwards and falls like a feather.

if(Game.inputManager.GetKey("Jump").KeyPressed())
{
    yForce = 1000f;
    this.rigidbody2D.AddForce(Vector2.up*yForce);
}

And using another suggestion I distribute the force over a second of time.

if(Game.inputManager.GetKey("Jump").KeyPressed())
    {
        addForceTimer = 1;
        yForce = 1000f;
    }
    addForceTimer -= Time.deltaTime;
    if(addForceTimer > 0)
    {
        this.rigidbody2D.AddForce(Vector2.up*yForce* Time.deltaTime*4);

    }

And I get a more desirable but still just as wrong movement where there is no hang at the top of the jump.

From what I thought I knew neither of these should be happening at all. The object shouldn't be falling at a constant speed like it is. Does anybody have any suggestions?

The character is animated if that can possibly have some sort of effect but I don't imagine it would.


texts: Perlin noise terrain: 3 coordinates from one

texts: I am making a game with procedural terrain, like minecraft. I have a perlin noise function which takes one integer and returns a number between zero and one. However, for terrain, I need a single density value from three coordinates: x, y and z. But my noise function only takes one number. Should I take the average of the noise values for x, y and z for a single density value? Or something else?


texts: Computer animation in C++ and if it can be integrated in web designes

texts:
I have a PhD in Mathematics with some experience in C++ programming. I am very interested in computer animation, and would like to try to teach myself in C++.

My humble resources at the moment are: Borland Builder 6 and a Toshiba laptop with 1.49 GG of ram and a maths co-processor. Please give me as generous advise as you can, detailing what resources are essential, and if at all possible give me some idea of cost.

Finally, is it possible to integrate animation created in C++ in web design?

Thank you in advance for your help.


texts: Why is xcode not letting me use my static variable?

texts:
I'm pretty sure I'm making some stupid mistake.
Can't seem to find it, and no good results when googling it either.

When I run my SDL project I get these errors :

  Undefined symbols for architecture x86_64:   "Input::evnt", referenced
  from:
        Input::ProcessInput() in Input.o ld: symbol(s) not found for architecture x86_64 clang: error: linker command failed with exit code
  1 (use -v to see invocation)

I know these are the lines that are causing the error :

switch (evnt->type)
{
    case SDL_KEYDOWN:
        std::cout << "Key pressed" << std::endl;
        break;

}

I know it's not the "contains" of the while loop, but the while loop itself.

This is what my evnt variable looks like :

static SDL_Event* evnt;

Not sure what I'm doing wrong....


texts:
When creating and rendering a skybox with a cube map texture, the skybox is black.

Here is how I create the cube map texture:

GLuint loadCubemap(std::vector<std::string> faces)
{
    GLuint textureID;
    glGenTextures(1, &textureID);
    glActiveTexture(GL_TEXTURE0);

    int width,height;
    unsigned char* image;

    glBindTexture(GL_TEXTURE_CUBE_MAP, textureID);
    for(GLuint i = 0; i < faces.size(); i++)
    {
        image = SOIL_load_image(faces[i].c_str(), &width, &height, 0, SOIL_LOAD_RGBA);
        glTexImage2D(
                    GL_TEXTURE_CUBE_MAP_POSITIVE_X + i, 0,
                    GL_RGB, width, height, 0, GL_RGB, GL_UNSIGNED_BYTE, image
                    );
    }
    glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
    glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
    glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
    glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
    glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_R, GL_CLAMP_TO_EDGE);
    glBindTexture(GL_TEXTURE_CUBE_MAP, 0);

    return textureID;
}

Here is how I draw the cube map:

void Skybox::update()
{
    //the sky box should be in the background
    glDepthMask(GL_FALSE);

    //set the position of the skybox around the camera
    pos = Camera::getCurrentlyBound()->getPos();

    //faces of the cube map
    std::vector<std::string> faces = {
        "/home/a/Programming/GameEngine/Game/Assets/skybox_px.png", //+x
        "/home/a/Programming/GameEngine/Game/Assets/skybox_nx.png", //-x
        "/home/a/Programming/GameEngine/Game/Assets/skybox_py.png", //+y
        "/home/a/Programming/GameEngine/Game/Assets/skybox_ny.png", //-y
        "/home/a/Programming/GameEngine/Game/Assets/skybox_pz.png", //+z
        "/home/a/Programming/GameEngine/Game/Assets/skybox_nz.png", //-z
    };

    //create the texture object
    GLuint cubeMap = loadCubemap(faces);

    //set up some matrices
    glm::mat4 modelMatrix = glm::translate(glm::mat4(), pos)*glm::mat4_cast(orien);
    glm::mat4 mvpMatrix = Camera::getCurrentlyBound()->getVP()*modelMatrix;

    //you can ignore this part
    Program* prog = ProgramManager::getProgram(msh.getProgramPath());

    //bind the program
    prog->bind();

    //set uniform data
    prog->setUniformData(mvpMatrix, "MVP");

    //bind the VAO
    msh.bind();

    //bind the cube map texture
    glBindTexture(GL_TEXTURE_CUBE_MAP, cubeMap);

    glDrawElements(GL_TRIANGLES, msh.getNumVerts(), GL_UNSIGNED_INT, 0); //draw

    msh.unbind(); //unbind the VAO

    prog->unbind();

    glDepthMask(GL_TRUE);

}

And here are the shaders:

Vertex Shader:

#version 330 core

in vec3 pos;

uniform mat4 MVP;

out vec3 fragTexVector;

void main()
{
    gl_Position = MVP*vec4(pos, 1);
    fragTexVector = pos;
}

Fragment Shader:

#version 330 core

out vec4 finalColor;

in vec3 fragTexVector;

uniform samplerCube skybox;

void main()
{
    //finalColor = vec4(1,1,1,1);
    finalColor = texture(skybox, fragTexVector);
}

I have scanned over this piece of code and over my entire project many times to find what was wrong and could not find anything. The samplerCube seems to always get black pixels.

Extra Information (might be helpful, I'm not sure):

I have tried debugging the program with VOGL (Valve's opengl debugger) but when I try to capture a snapshot of a frame it crashes with an error:

Internal error: KTX texture failed internal consistency check, texture 7 target GL_TEXTURE_CUBE_MAP. This should not happen!

I'm very new to OpenGL and if anybody with OpenGL experience could help me with issue it would be greatly appreciated.

Thanks.


texts: Can I use a translate function to implement a viewport?

texts:
I read this great question and its accompanying great answer about rendering a viewport in a top down 2D game:

  As for actually drawing the objects the camera can "see", you now draw all objects relative to the camera's world coordinates. To compute an object's screen position relative to the camera, simply do:

int screenX, screenY; //screen position of the object being drawn

screenX = object.x-camera.x;
screenY = object.y-camera.y;

After thinking about this, it would be really invasive to change every place I render to run this object.coord - camera.coord equation first.

I'm wondering if this could be accomplished in one non-invasive step that translates the coordinate system first.  I'm rendering on the html5 canvas and this translate function says:

  Moves the origin point of the context to (x, y).

I'm having trouble visualizing this though.  Does this mean I simply plug (-camera.x, -camera.y) into the function?  Should I use a translate function to render a viewport or is there a good reason to apply the equation on every thing I render?


texts: Is there a good guide on terrain topography creating?

texts:
I want to create a map for my level, and to make it look realistic from topographical pont of view.  Is there anything that you can recommend?

Edit:
I want to create a 3D map of islands, sea, volcanoes, shores, that will look natural.
Suppose that I want to write the map generator by myself.
Are there any resources on natural land topography?
Examples :

The sea level should be the same anywhere.
Sand should be near the shore.
There is no way that there will be a huge mountain in the middle of the shore


texts: Sprite animation cannot be play when player retry Unity

texts:
In my unity2d game I've create a sprite animation, like a mushsroom bounce.

When I start the game for the first time the animation plays properly, but when the player dies, and retries, the animation won't play. I cannot reload the scene, I have to reset the player's transform.position.

How can I solve this problem?

if (target.tag == "Masroom") {
        target.gameObject.GetComponent<Animator> ().enabled = true;
        playerRigidBody.velocity = new Vector2(0,8);
    }


texts: Should I take line thickness into consideration for a grid based light game?

texts:
I'm currently rewriting some horrific code I wrote for a prototype and have stumbled right at the start! The game I'm working on revolves around directing light and there is a small ambiguity in regards to the way the grid is drawn:

Code wise, information about each node of the grid is stored in an int[,], the grid lines are drawn for debugging purposes. Currently there is nothing explicitly defined for the line thickness, i.e if you look at the pixels closely, the bottom and right lines are drawn in a way which means the grid is not centered on screen, it is one pixel out!

If you shrink the scale of the grid to each being cell being 4x4 pixels the problem is really obvious:

The red area is the cell; the lines show how I draw the grid lines and what the light beams travels across. Would it better to represent this as a grid of 3x3 pixel cells with a line thickness of 1?

Normally I wouldn't be bothered too much because this is really looking into it in a lot of depth, but since the lines of light themselves actually traverse these currently non-existing lines I thought it might be better to make the representation a more elegant! What do you think?


texts: Dropping multiple objects using an array in Actionscript?

texts:
I'm trying to get these fireBalls to drop more often, I'm not sure if I'm using Math.random correctly.

Also, for some reason I'm getting a null reference because I think the fireBalls array waits for one to leave the stage before dropping another one?

This is the relevant code:

var sun:Sun=new Sun
var fireBalls:Array=new Array()
var left:Boolean;

function onEnterFrame(event:Event){
    if (left) {
        sun.x = sun.x - 15;
    }else{
        sun.x = sun.x + 15;
    }
    if (fireBalls.length>0&&fireBalls[0].y>stage.stageHeight){ // Fireballs exit stage
        removeChild(fireBalls[0]);
        fireBalls.shift();
    }
    for (var j:int=0; j<fireBalls.length; j++){
        fireBalls[j].y=fireBalls[j].y+15;
        if (fireBalls[j].y>stage.stageHeight-fireBall.width/2){
        }
    }
    if (Math.random()<.2){ // Fireballs shooting from Sun
        var fireBall:FireBall=new FireBall;
        fireBall.x=sun.x;
        addChild(fireBall);
        fireBalls.push(fireBall);
    }
}


texts: XNA: How to make the Vaus Spacecraft move left and right on directional keys pressed?

texts:
I'm currently learning XNA per suggestion from this question's accepted answer:
Where to start writing games, any tutorials or the like?

I have then installed everything to get ready to work with XNA Game Studio 4.0.

  General Objective

Writing an Arkanoid-like game. I want to make my ship move when I press either left or right keys.

  Code Sample

    protected override void Update(GameTime gameTime) {
        // Allows the game to exit
        if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed)
            this.Exit();

        // TODO: Add your update logic here
#if WINDOWS
        if (Keyboard.GetState().IsKeyDown(Keys.Escape))
            this.Exit();
        else {
            if (Keyboard.GetState().IsKeyDown(Keys.Left))
                MoveLeft(gameTime);
        }
#endif

        // Move the sprite around.
        BounceEnergyBall(gameTime);

        base.Update(gameTime);
    }

    void MoveLeft(GameTime gameTime) {
        // I'm not sure how to play with the Vector2 object and its position here!...
        _vausSpacecraftPos /= _vausSpacecraftSpeed.X; // This line makes the spacecraft move diagnol-top-left.
    }

  Question

What formula shall I use, or what algorithm shall I consider to make my spaceship move as expected left and right properly?

Thanks for your thoughts! Any clue will be appreciated. I am on my learning curve though I have years of development behind me (already)!


texts:
I need a word list to use in a commercial game (even though the game will be free to download)

Something like this

http://www.puzzlers.org/pub/wordlists/ospd.txt

Would be perfect (needs to be formatted .txt file) but obviously allowed to be used in a commercial game. I'm happy to pay if it's not too much.

Thanks for any advice.

UPDATE

After some more research (google), I came across this passage. Thought this might be useful for other people, although it still seems in contradiction to what the replies are saying on stack overflow here

"The nearest thing to a licence text for ENABLE, of which ABLE forms a part, is as follows.

The ENABLE master word list, WORD.LST, is herewith formally released
into the Public Domain. Anyone is free to use it or distribute it in
any manner they see fit. No fee or registration is required for its
use nor are "contributions" solicited (if you feel you absolutely
must contribute something for your own peace of mind, the authors of
the ENABLE list ask that you make a donation on their behalf to your
favorite charity). This word list is our gift to the Scrabble community,
as an alternate to "official" word lists. Game designers may feel free
to incorporate the WORD.LST into their games. Please mention the source
and credit us as originators of the list. Note that if you, as a game
designer, use the WORD.LST in your product, you may still copyright and
protect your product, but you may not legally copyright or in any way
restrict redistribution of the WORD.LST portion of your product. This
may under law restrict your rights to restrict your users' rights,
but that is only fair.

M Cooper and Alan Beale
"

From this site
http://www.quinapalus.com/dicts.html

Obviously I have no way of knowing if that's legit or not, so I was wondering what other peoples advice still is.


texts: Stitch a collection of images into a tileset

texts: I have a number of tiles as standalone files that I would like to stitch together into a single tileset. Are there any tools that can quickly do this?


texts: Air AS3 Desktop - Detecting wrong screen resolution and coordinate offset

texts:
I have an issue with developing an Air desktop app using FlashDevelop in ActionScript 3.0

I'm pretty much new to all this, but I think I made all I should and am wondering if this could be some bug outside my code.

My screen and desktop composition is as follows:

1x Surface pro 3 with Multitouch 2160x1440 screen on the left (Identified as Screen 1)
1x Dell P2314T Multitouch with 1920x1080 screen in the middle (Identified as Screen 2)
1x Dell P2314T Multitouch with 1920x1080 screen on the right (Identified as Screen 3)

When I run Air app with fullscreen mode with

stage.displayState = StageDisplayState.FULL_SCREEN;
stage.scaleMode = StageScaleMode.NO_SCALE;

I get it on the Surface's screen on fullscreen, it being the windows Main display. If I trace the stage.nativeWindow.width and stage.nativeWindow.height I get the correct resolution.

Now since I wanted the app to run on the 23" screen, I set Screen 2 to be the Main display in windows. Now AIR app is ran on the screen 2 by default, thus reporting the stage width and height being 1920 and 1080. However, the child sprites I have on stage with coordinate x = 0 are outside my screen area! They are not visible on the screen on the left, but simply hidden like they're outside of the stage. If I put first child x offset to 120 (half of the difference between 1920 and 2160 screen widths), it's positioned approx on the left edge.

To see better what's going on, I went to screen resolution manager and disabled the internal Surface's screen completely ("Don't show desktop on this screen", thus leaving me with 2x 1920x1080 screens only.

If I run the code now, the stage.nativeWindow.width and height are reporting resolution of 2160x1440 - that's screen 1, which is disabled and has no image on it at all.
The Sprite x offset issue remains the same, being 120 in minus.

The code is completely clear, having stage with single sprite and quad drawn.

public class Main extends Sprite
    {

        static public var instance:Main;

        public function Main()
        {
            instance = this;
            Multitouch.inputMode = MultitouchInputMode.TOUCH_POINT;
            stage.displayState = StageDisplayState.FULL_SCREEN;
            stage.scaleMode = StageScaleMode.NO_SCALE;
            stage.nativeWindow.alwaysInFront = true;

            trace( String(stage.nativeWindow.x) + ' y: ' +
            String(stage.nativeWindow.y) + ' size h: ' +
            String(stage.nativeWindow.height) + ' w: ' +
            String(stage.nativeWindow.width) );
            init()
        }

        private function init():void
        {
            frame = new Sprite
            frame.x = 120;
            frame.y = 450;
            addChild(frame);
            trace('frame x: ' + frame.x);

        }

    }

What could possibly cause such error? Could someone confirm whether this error is reproducible?

Thanks!

Edit 1:

Ok, seems like the failed offset was fixed adding the stage align property in main:

stage.align = StageAlign.TOP_LEFT

I'm still interested to know why the runtime default align happens using scree 1 instead of main's resolution, and therefore fails to be correct though!

The magic about wrong resolution still stays the same, and can't be reproduced using two different screens (AOC 1920x1080 and Dell 1920x1200) in same composition, using same settings. Weird...


texts: Rigidbody2D without pushing eachother on collision

texts:
TLDR; How to stop movement if two Rigidbodies collides?

Also,  here's a potato video of the problem: https://gfycat.com/ComposedArcticBetafish

Say I have three objects in a scene:

Player
Enemy
Rock

The player and enemies is moving freely, but the rock is static. So I attached a Rigidbody2D on player and enemy to move them around with script. All of them has a Box Collider 2D.

Now, if I (Player) move into an Enemy, I will start to push it (changing its position). I don't want this.
I can set the Enemy's mass to something large, but then two enemies can still push eachother. I don't want this. If I try kinematic solutions I've found, but then they can move through the rock.

I want:

Player can not move enemies
Enemies can not move players
Enemies can not move each other
Nothing can move or go through the rock
Enemies can not move through player
Player can not move through enemies

I keep reading that if I'm moving colliders, I should also use Rigidbodies for performance. But I can't see how I get this to work with Rigidbodies.

How do I set it up? Or should I move away from rigidbodies and set it up myself?


texts: What is the difference between OpenGL ES and OpenGL?

texts: Android uses OpenGL ES, what is the difference between it and OpenGL?


texts: Tile-based multiplayer game: server and client load

texts:
I'm developing a multiplayer tile-based game (imagine habbo) and having some trouble with the movement. The idea is to click on a tile (target tile) so your avatar moves there and everyone can see you moving there. In order to do that, there's a pathfinding function.

My first approach was: the pathfinding function was in the client and everytime the avatar moved a pixel (guided by the pathfinder) it sent a message to the server which broadcasted this update. This was obviously mad.

My second approach was to send to the server just the target tile. The server broadcasted this target tile, and each client ran the pathfinding function for each avatar in movement. I found problems with this because of synchronization: imagine two users moving that pass through the same tile at different times, maybe in one client with a little lag it happens that they pass through the same tile at the same time, so the pathfinder will stop one of them, as you can't walk over another avatar. This will lead to different positions in each client.

I've read some cases where the pathfinder runs in the server, the client just send the target tile and receives every x mseconds an update from the server with the pathfinding calculations for every avatar in movement (even himself). The problem I find here is how to set this "x mseconds" and that it might mean a lot of load to the server, handling all the pathfinding calculations...

What are the pros and cons of each approach?


texts:
I'm writing a platformer and I want to implement own art, now I know how to display it and this isn't my question. It rather is how do I remove it?
I tried drawing a rectangle over it and removing it, but that doesn't seem to work, here's my code:

function clearImage(id) {
    for (var i = 0; i < 6;) {
        if (img_id[i] == id) {
            console.log(img_loc_x[i]);
            console.log(img_loc_y[i]);
            ctx.fillRect(img_loc_x[i], img_loc_y[i], "1000", "1000");
            ctx.clearRect(img_loc_x[i], img_loc_y[i], "1000", "1000");

            img_loc_x[i] = null;
            img_loc_y[i] = null;
            img_id[i] = null
            console.log("Cleared image with id: "+id+" succesfully!");
        } else {
            i++;
        }
    }
}

I'm using some arrays to store the image data such as the location and an id form management, but I didn't implement a method yet to get the dimensions of it, thats why I'm giving it the size parameters.
(Strangely it works if I enter the fillRect and clearRect commands in the console)


texts: Poor image quality on Android through Unity Remote

texts:
I have started to work on the company's latest project using Unity3D and the workflow is just awesome.

The problem is when running the game on a real Android device (using Unity Remote) the image quality is very poor in comparison to how it looks in the editor:

(Click for a full view. Look at those sprite edges.)

Is this...

caused by the phone's limited graphics capabilities
or have I configured the project improperly
or is it Unity Remote and actually building it for Android will fix the quality? (Based on Unity Answers site, Unity Remote is the cause : http://answers.unity3d.com/questions/408896/android-image-quality-is-poor-compared-to-the-qual.html#comment-408945)


texts: Detecting collision with a 3D array of boxes

texts:
I am at the stage of my development process where I want to implement collision. Now I can think of a simple way of doing it, if the camera's x, y or z are inside the position of a certain cube then don't let the camera move in the direction it hit the object. Seems simple enough.

The thing is I think this will be pretty intensive for collision detection. I am using a 3D array for my cubes, and I think there maybe is a way to simplify it by using this array. I just don't know how. If there isn't a way because the camera can move freely is the idea that I suggested a good way of doing collision? It will only be run on one group of cubes, the one you are above at X point in time. Cubes are static at every point in time.


texts: If you are a solo programmer, how do you manage the graphics artistry part?

texts:
If you are a solo programmer creating a game, what do you do for the graphics and art part?

Should I work with graphics artist to draw the characters and the environment? I don't know how to draw any way.


texts: HLSL Shadow Mapping occurs only around player

texts:
I've recently begun playing around with Monogame (OpenSource "remake" of XNA). My current task is to write a simple shadow mapping shader. After following Riemer's XNA Tutorial I got the shadows to show up. But interestingly only around where the "player" (camera) is. When I'm outside of the light's radius there's no light showing up around the camera (which is good), but the light from my spotlight should of course still be there. But it's not. The shadows and the bright lighting from my spotlight only appear around player.

As I said, my HLSL code is exactly the same as Riemer's (Except that I wrote SV_POSITION instead of POSITION0 at the VertexShaderInput struct because MonoGame only supports Pixel-/Vertexshader 4.0 and above)

I also have a feeling that my Light-View/-Projection Matrices might somehow be wrong:

Matrix lightsView = Matrix.CreateLookAt(lightPos, new Vector3(lightPos.X, lightPos.Y-1, lightPos.Z), new Vector3(0, 0, 1));
Matrix lightsProjection = Matrix.CreatePerspectiveFieldOfView(MathHelper.ToRadians(45F), 1f, 1f, 10f);

(I know that my "up" vector is not pointing upwards; that was the only way I got the light to point downwards from it's position, otherwise it would always point to (0 -1 0) even if I wrote it so that the lights coordinates were used and then it would go y -1 from the light - really weird...)

I really hope someone knows what's up here, this issue prevented me from doing anything else in my code for a couple of days now...

PS: Here's my rendering code:

    ////In my Model-Class
    private void DrawModel(string tech)
    {
        Matrix[] transforms = new Matrix[model.Bones.Count];
        model.CopyAbsoluteBoneTransformsTo(transforms);

        foreach (var mesh in model.Meshes)
        {
            foreach (ModelMeshPart part in mesh.MeshParts)
            {
                part.Effect = Game1.effect;
                Matrix tempWorld = ((transforms[mesh.ParentBone.Index] * Matrix.CreateScale(scale)) * rotationMatrix) * Matrix.CreateTranslation(pos);
                part.Effect.CurrentTechnique = part.Effect.Techniques[tech];
                part.Effect.Parameters["xWorldViewProjection"].SetValue(tempWorld * Game1.camera.View * Game1.camera.Projektion);
                part.Effect.Parameters["xTexture"].SetValue(textures[part]);
                part.Effect.Parameters["xWorld"].SetValue(tempWorld);
                part.Effect.Parameters["xLightPos"].SetValue(Game1.currentLevel.lightPos);
                part.Effect.Parameters["xLightPower"].SetValue(Game1.currentLevel.lightPower);
                part.Effect.Parameters["xAmbient"].SetValue(Game1.currentLevel.ambientPower);
                part.Effect.Parameters["xLightsWorldViewProjection"].SetValue(tempWorld * Game1.currentLevel.lightsViewProjectionMatrix);
                part.Effect.Parameters["xShadowMap"].SetValue(Game1.currentLevel.shadowMap);
            }

            mesh.Draw();
        }
    }

    ////In my Level-Class
    public void Render()
    {
        var device = Game1.graphics.GraphicsDevice;

        device.SetRenderTarget(renderTarget);
        device.Clear(ClearOptions.Target | ClearOptions.DepthBuffer, Color.Black, 1.0f, 0);

        DrawScene("ShadowMap");

        device.SetRenderTarget(null);
        shadowMap = (Texture2D)renderTarget;

        device.Clear(ClearOptions.Target | ClearOptions.DepthBuffer, Color.Black, 1.0f, 0);
        DrawScene("ShadowedScene");
    }

    private void DrawScene(string tech)
    {
        foreach (var model in models)
        {
            model.Render(tech);
        }
    }

and the light-update code:

private void UpdateLightData()
    {
        ambientPower = 0.2f;

        lightPos = new Vector3(-0.2F, 1.2F, 1.1F);

        lightPower = 1.8f;

        Matrix lightsView = Matrix.CreateLookAt(lightPos, new Vector3(lightPos.X, lightPos.Y-1, lightPos.Z), new Vector3(0, 0, 1));
        Matrix lightsProjection = Matrix.CreatePerspectiveFieldOfView(MathHelper.ToRadians(45F), 1f, 1f, 10f);

        lightsViewProjectionMatrix = lightsView * lightsProjection;
    }


texts: I was wondering if any scene graph-like mechanism is implemented into Unity3D? For example if I have a GameObject, can I add child cubes to it so when I rotate the parent GameObject, the siblings will rotate too?


texts: How do I make an XML-specified animation show completely?

texts:
I want to add animation to my game board when updating tile positions. I can start an animation at the right point, but there's a catch: When the translate animation starts, it seems like the animation is confined within the tile (button) or is just hidden behind another button. Instead, I want it to look like it is moving.

This is what happens:

This is what I want to happen:

Here's how I start the animations:

    Animation tile_up = AnimationUtils.loadAnimation(this, R.anim.tile_up);
    // This was a valid move. Add to moves and enable undo for this
    for(int i = 0; i < 5; i++)
    {
        buttons[x][i].startAnimation(tile_up);
    }

Here's the animation spec (in res/anim/tile_up.xml):

    <?xml version="1.0" encoding="utf-8"?>
    <translate
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:shareInterpolator="true"
        android:fromYDelta="100%p"
        android:toYDelta="0%p"
        android:duration="100"/>

How can I fix this?


texts: Resultant Vector Of Circle Line Collision

texts:
For my game I need to have a circle collide against a wall and bounce off in the appropriate direction. I've looked around for a while and haven't found a good solution to my problem. I have a diagram of what should happen below.

The problem is that I have the vector V, U, and P, but I am unable to calculate the new X and Y vectors after the collision. I have tried using Trig to find the angle of the intersection and get the new X and Y vectors from that but it gives massive numbers.
How do I get the new X and Y vectors easily?
Source code is posted below.

for (int i = 0; i < collisionList.size(); i++){
    Vec2<Integer> c = collisionList.get(i);
    int cx = c.getX();
    int cy = c.getY();
    if (distance(x, y, cx, cy) <= (r - (r / 2))){
        float mag = (float)Math.sqrt((Math.pow(x, 2) + Math.pow(y, 2)));
        float angleRad = (float)Math.atan(y / x);

        xVel = (float)(mag * Math.cos(angleRad));
        yVel = (float)(mag * Math.sin(angleRad));
    }
}


texts: Unity WebGL player just shows black screen

texts:
I built my Unity project with WebGL. After load the resources, I can hear the music and player sounds(movements etc), but it just display black screen only. I found some similar situation in google, but couldn't find the way to fix.

Here's the console result:
https://drive.google.com/open?id=14Uhd6SBbDHdPN39TurY9H7QPGhPLfb_X

Used Unity 2018.2.1f1, tested with Chrome 73.0.3683.86.


texts: What is required for casting shadows in JavaFX 8 3D?

texts: In a scene with an added point light the shapes are not casting shadows on each other. Is anything required to cause them to cast shadows?


texts: Unity3D - Resources load to materials, how to?

texts:
I think is a simple question, but I don't know nothing about it:

I have an created material in my materials folder, I just want to apply it to the GameObject by script.

I am trying

this.GetComponent<Renderer>().materials[0]=Resources.Load("Test", typeof(Material)) as Material;

The material name is Test and it is in materials folder, but the return is always the default material applied to the GameObject, so I think Unity didn't found it.


texts: How do I use virtual joysticks in Unity2d ()top view?

texts:
I want to use virtual joysticks for character movement, in a top-down 2D game, that includes rotating the character.

I tried an Easy Joystick Unity Package, but it doesn't work properly, so what do I do?
Does anyone have a script (preferably in C#) that would use virtual joysticks to move a character?


texts: Incomplete mesh using DrawIndexedPrimitives after rotating mesh

texts:
Through help on this site I was able to draw the triangles of an unrotated, nonscaled nontransformed mesh created in Blender and exported to OBJ, accurately imported through Assimp and rendered in XNA Graphics.
However after applying rotation on a single axis in Blender(Z) and adding materials(I wanted to test loading of materials through Assimp) the same mesh appears incomplete. Is something wrong with my view matrix or is it something else?

This is what the unrotated mesh looks like:

Here is the rotated mesh:

Camera, View and Projection are defined as follows:

cameraPos = new Vector3(0, 5, 9);
viewMatrix = Matrix.CreateLookAt(cameraPos, new Vector3(0, 0, 1), new Vector3(0, 1, 0));
projectionMatrix = Matrix.CreatePerspectiveFieldOfView(MathHelper.PiOver4, device.Viewport.AspectRatio, 1.0f, 200.0f);

Rendering is done through this code:

device.Clear(ClearOptions.Target | ClearOptions.DepthBuffer, Color.DarkSlateBlue, 1.0f, 0);
effect = new BasicEffect(GraphicsDevice);
effect.VertexColorEnabled = true;

effect.View = viewMatrix;
effect.Projection = projectionMatrix;
effect.World = Matrix.Identity;

foreach (EffectPass pass in effect.CurrentTechnique.Passes)
{
    pass.Apply();
    device.SetVertexBuffer(vertexBuffer);
    device.Indices = indexBuffer;
    device.DrawIndexedPrimitives(Microsoft.Xna.Framework.Graphics.PrimitiveType.TriangleList, 0, 0, oScene.Meshes[0].VertexCount, 0, mMesh.FaceCount);
}
base.Draw(gameTime);


texts: How to write a custom WaitUntil that is reusable?

texts:
In my turn based game, I like to have a function similar to Unity's WaitForSeconds, WaitUntil that can be called within a IEnumerator that suspends the coroutine execution for the given amount of moves. I already have a public working UnityEvent (moveEvent) which I could listen to.

So I could call it from any IEnumerator like:

IEnumerator Example()
{
    yield return new WaitForMoves(2);
}

I think I'd need a separate class like:

class WaitForMoves {

  int moves = 0;

  void Start() {
    Game.moveEvent.AddListener(OnMoveComplete);
  }

  void OnMoveComplete() {
     moves++;
  }

  // I'm not sure how to write this in a way that it waits
  // until this.moves === movesToWait
  public WaitForMoves(int movesToWait) {

  }
}


texts: Sprite quickly disappears after rendering

texts:
I'm currently making space invaders and I'm using the game loop pattern as described here. I have an entity class from which there is a spaceship derived class. The base entity class contains all of the general entity data such as the x/y position, speed, etc...
Currently, I have the X and Y positions initialized to (0,0) so the spaceship is rendered in the center of the screen. I tried initializing the y position to a different coordinate corresponding to a position, but for some reason, the spaceship just keep moving vertically as if the y position is just being accumulated at each frame. I think the problem is caused by the fact that in my render() method of the spaceship class, I'm translating the modelmatrix with the x and y position of the spaceship as that would explain why there isn't vertical movement when the coordinates are (0,0). I'm not sure exactly if this is the proper way to structure the render() method but I couldn't think of another way to change the object's position. Below is the relevant code:
Spaceship class definition:
class Spaceship : public Entity {
public:
    Spaceship(float xDirect, float yDirect,
        float xPosition, float yPosition, float speed, float rState, ShaderProgram* program, SheetSprite newSprite, bool movingLeft, bool movingRight):
        Entity(xDirect, yDirect, xPosition, yPosition, speed, rState, program, newSprite), movingLeft(movingLeft), movingRight(movingRight)
    {
        posY = 0.1;
    }

    virtual void Update(float elapsed) {
        // move stuff and check for collisions

        if (movingLeft) {
            posX -= elapsed* 0.001;
        }

        else if (movingRight) {
            posX += elapsed * 0.001;
        }
    }

    virtual void Render() {
        setOrthoProj();
        setObjMatrices();
        translateObj(posX, posY, 0.0);
        mySprite.Draw();
    }
    bool movingLeft;
    bool movingRight;
};

Initialization Code in main
Spaceship* spaceship = new Spaceship( 1.0f, 1.0f, -5.1f, 0.0f, 3.0f, 0.0f, program,mySprite, false, false);
    spaceship->Render();

Game Loop movement code
    const Uint8 *keys = SDL_GetKeyboardState(NULL);

    if (keys[SDL_SCANCODE_LEFT]) {
        spaceship->movingRight = false;
        spaceship->movingLeft = true;
        spaceship->Update(elapsed);

    }
    else if (keys[SDL_SCANCODE_RIGHT]) {
        spaceship->movingLeft = false;
        spaceship->movingRight = true;
        spaceship->Update(elapsed);

    }
    spaceship->Render();

For some reason, the first render() call outside of the loop isn't rendering the spaceship, only the one inside the loop works.
Given the structure of the program, what could be causing the problem?
EDIT
Translate method from Entity base class
void translateObj(float x, float y, float z) {
        posX = x;
        posY = y;
        modelMatrix.Translate(posX, posY, 0.0);
    }

void setObjMatrices() {
        glUseProgram(program->programID);
        program->setModelMatrix(modelMatrix);
        program->setProjectionMatrix(projectionMatrix);
        program->setViewMatrix(viewMatrix);

    }


texts: I have problem understand instantiating new objects in Unity at runtime , help please :)

texts:
Hi again you fine folks.

So I'm making a driving game and there is going to be some cows in the road you have to dodge.

Currently I've laid 3 spawnpoints in the form of flat cubes, with the following script attached to each of them. (The reason I am manually laying the spawn points out myself is that the road is very windy, and has steep hills etc , and I was struggling to find a way to prodecurally place them on the road exactly at correct height etc.

Here is the code im using for these spawn points. For some reason I am getting all 3 cows spawn on the first spawn point, instead of just one. I haven't driven the car thru to the other 2 spawn points, id guess there'd be 3 cows at each of them. (I have to actually build to my phone to get that far due to the controls being for mobile not PC):

public class CowSpawn : MonoBehaviour {
public GameObject bullPrefab;
public float spawnChance;
bool willSpawn = false;

private GameObject bull;

// Use this for initialization
void Start()
{
    if (Random.value < spawnChance)
    {
        willSpawn = true;
    }

    bull = (GameObject)Instantiate(bullPrefab);
    bull.transform.position = GetComponent<GameObject>().transform.position;

}

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

}

}


texts: Separating Axis Theorem and rotated objects

texts:
Quick question which hopefully won't require thralling through my code.

I have a working implementation of SAT for 3D collision detection but I'm having some problems with dealing with rotated objects. So what I have done, is every frame I rotate every point in both objects by their rotation quaternions. This feels excessive, especially if I am going to be translating/scaling/rotating every vertex in every object on every frame for the collision detection.

I would hope there's a way of implementing my SAT implementation to work with rotated normals only, and not need the rotated projections to compensate, but that doesn't seem to be working.

Could anyone provide me with a brief explanation with how SAT should be expected to handle rotations? Can we rotate certain points, or perhaps get some sort of post-projection rotation value to skew our projections like we can with translations?

Thanks


texts: Make a square flickering at a preset frequency

texts:
I'm working on a medi-sci project where I want the patient to use brainwaves to exercise control the environment.

The environmnet is a 2D game where the game character is to be controlled by 2 flickering squares. Each square are supposed to be on different frequencies e.g. 7Hz and 9Hz. They should flicker between black and white.

These frequencies will be measured on the brain and used to move the characters in a BCI solution. The project is being made in Unity and in c#.

I tried to use the animator and the Update function in Unity to get a flickering but it didn't work out (Read: It was very bad) because when the game became slow so did the flickering. I couldn't use that.

A friend told me that there's a difference between CRT and LCD screens so the refresh rate is different and can't be used the same way.
I was also told to look into Timer.Interval in C# (or just the Timer class) and use that to switch between black and white squares to get the right frequency.

Is there anyone who could show me how to do this the right way in unity with C#?
I mean how can I use Timers.Interval or System.Timers.Timer (or something else in the Timer class) to give me the right frequency in Unity?

I would prefer an example because I can't see any way of getting to the solution at all...


texts:
I want to draw a 2d polygon map based on data provided by another source to ease analysing actions on the map. The data has the following format:

1 ['2', '4', '5', '7', '17', '10']
2 ['1', '3', '4']
3 ['2', '11', '4']
4 ['1', '2', '3', '11', '13', '18', '5']
5 ['1', '4', '18', '17']
6 ['7', '8']
...

The first number is the ID of a node, the following list contains the IDs of its neighbours. As a node's number of neighbours differs I need to draw a polygon map.

So I tried to use Voronoi polygons for the map representation. The problem is: How can I determine the points to satisfy all neighbourhood relations? I guess my first try is more or less an error in my try and error cycle. I used the sfdp tool of graphviz to get the point positions of the graph:

Using the positions of the points resulted in the following map representation:

The problem of this approach is that for example nodes 4 and 1 are neighbours but in the Voronoi diagram they aren't because of the position of the nodes. So for me this approach failed.

Googling, I found a lot of tutorials generating maps with polygons or tiles but I haven't found out yet how I can create a map for my given data. I guess there is an approach using (multiple) hexagons/triangles/squares or a mixture to achieve what I need but I don't know what I shall search for.

Is there a keyword or an algorithm which can help me here?

Update/Result: For completeness: This is my result after using the suggestions of the accepted answer:


texts: Drawing textures off screen optimization required?

texts:
I recently started using LibGDX and I am wondering if I have to optimize my code when drawing textures/sprites off-screen, just like I used to do with XNA.

My biggest concern here is specifically for the TiledMapRenderer.render() method, which draws a tiled map, imported from the Tiled map editor software.

I don't know how reliable this test I tried was (I just used the Sprite and SpriteBatch class here), but here it is:

// Doesn't cause frame drop
spriteBatch.begin();
for (int i = 0; i < 50000; i++) {
    mySprite.setPosition(i, i); // most of times this is off-screen
    mySprite.draw(spriteBatch);
}
spriteBatch.end()

// Less than 1 frame per second
spriteBatch.begin();
for (int i = 0; i < 50000; i++) {
    mySprite.setPosition(0, 0); // always inside the screen view
    mySprite.draw(spriteBatch);
}
spriteBatch.end();

So, from what I observe, I assume that anything drawn outside of the screen with LibGDX is not being drawn, to improve performance. Is this the case ? If so, in what degree should I be abusing this feature ?

Is LibGDX just checking a couple of logical conditions with the camera/viewport I am using and the u,v coordinates I am trying to draw the texture to and determines if this texture should or should not be drawn ? Or is it a process that takes requires lot of resources from the system ? Keep in mind that I mostly care about the android devices.

Should I be worried about this at all ? Again, TiledMapRenderer.render() is my biggest concern here, but I would also like to know if there is an optimization with drawing textures off-screen in general as well.


texts: Regarding BGE (Blender Game Engine), is it possible to generate a single .exe file from multiple files linked together?

texts:
Would any of you guys or gals know the answer, please?

I know one can generate a .exe (windows executable) file from a single blend file. My question is very simple: Can anyone generate a single .exe file from multiple blender files of a same project?

For instance, say I have a project folder with several subfolders and files from my project game. Each folder has specific elements like scenes, models, textures, etc. They are all linked together to form the final game. Now I want to generate a single .exe file for my game. Is this possible?

Or, rather, should I make an entire game inside a single .blend file? (It seems like a very unlikely arrangement, maybe even impossible, but I rather ask). Or maybe even create a master .blend file from where to link all data and when project is finished pack everything before generating the executable (.exe)?


texts: HTML5 Canvas Converting between cartesian and isometric coordinates

texts:
I'm having issues wrapping my head around the Cartesian to Isometric coordinate conversion in HTML5 canvas. As I understand it, the process is two fold:

(1) Scale down the y-axis by 0.5, i.e. ctx.scale(1,0.5); or ctx.setTransform(1,0,0,0.5,0,0); This supposedly produces the following matrix:

[x; y] x [1, 0; 0, 0.5]

(2) Rotate the context by 45 degrees, i.e. ctx.rotate(Math.PI/4); This should produce the following matrix:

[x; y] x [cos(45), -sin(45); sin(45), cos(45)]

This (somehow) results in the final matrix of ctx.setTransform(2,-1,1,0.5,0,0); which I cannot seem to understand... How is this matrix derived? I cannot seem to produce this matrix by multiplying the scaling and rotation matrices produced earlier...

Also, if I write out the equation for the final transformation matrix, I get:

newX = 2x + y
newY = -x + y/2

But this doesn't seem to be correct. For example, the following code draws an isometric tile at cartesian coordinates (500, 100).

ctx.setTransform(2,-1,1,0.5,0,0);
ctx.fillRect(500, 100, width*2, height);

When I check the result on the screen, the actual coordinates are (285, 215) which do not satisfy the equations I produced earlier... So what is going on here? I would be very grateful if you could:

(1) Help me understand how the final isometric transformation matrix is derived;

(2) Help me produce the correct equation for finding the on-screen coordinates of an isometric projection.

Many thanks and kind regards


texts: working in external actionscript file does not show anything on the screen?

texts:
I'm writing this code in Flash builder and I tested the file in flash, but nothing appears in the swf file. (no text in the screen show , i don't know why) Is there any missing property in the code? Also, when I create text or movie clip with flash tools on the stage and give it an instance name, flash builder doesn't seem to recognize it in the action script code.

package
{
    import flash.display.MovieClip;
    import flash.text.TextField;

    public class mark extends MovieClip
    {

        public function mark()
        {

            super();
            public var d:TextField=new TextField();

            d.text="Hello world";
            d.x=250;
            d.y=300;
            addChild(d);

        }
    }


texts: Approximating particles with with nebula

texts:
I have a 2d galaxy where each star is rendered a particle:

I'd like to approximate it with nebula, so that instead of seeing lots of tiny dots from afar, users will see lots smooth light in the area. Something like this:

I'm more interested in technology-agnostic solution which accurately resembles underlying particles. E.g. how would one approach this problem from math/physics standpoint?

But if you have hints how to do it in a specific technology - those are welcome too! I don't even know how to approach it. The final thing is implemented with WebGL.


texts: Homing missile not following the target and not facing the direction of movement

texts:
I have been trying this for two days with no success. I cant figure out where I'm missing the point. All the missiles are moving towards the position of the target but not following it. The position remains fixed and all the newly created missiles come to this point instead of following the target.

Here is the code

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

public class HomingMissile : MonoBehaviour
{
    public Transform target;
    private Rigidbody rb;
    public float rotationSpeed;
    public float speed;

    Quaternion rotateToTarget;
    Vector3 direction;

    private void Start()
    {
        //target = GameObject.FindGameObjectWithTag("Target");
        rb = GetComponent<Rigidbody>();
    }

    private void Update()
{
    //direction = (target.transform.position - transform.position).normalized;
    //float angle = Mathf.Atan2(direction.z, direction.x) * Mathf.Rad2Deg;
    //rotateToTarget = Quaternion.Slerp(transform.rotation, rotateToTarget, Time.deltaTime * rotationSpeed);
    //rb.velocity = new Vector3(direction.x * speed, direction.y * speed, direction.z * speed);

    Vector3 direction = (target.transform.position - transform.position).normalized;
    float angle = Mathf.Atan2(direction.z, direction.x) * Mathf.Rad2Deg;
    Quaternion rotateToTarget = Quaternion.Euler(0, angle, 0);
    transform.rotation = Quaternion.Slerp(transform.rotation, rotateToTarget, Time.deltaTime * rotationSpeed);
    rb.velocity = direction * speed;
}

}

I selected the target(transform) using the inspector.
I'm using Unity and C# obviously you know that.

What Im trying to achieve is that the missile should follow the position of the target in real time. And i can add the destroy code for the missile myself.
Note :
Please don't tag this as a duplicate. It is not.
The game is 2D where Y is always constant. Vertical axis is X and Horizontal axis is X. The objects are 3D. That's why I can't use rigidbody2D.


texts:
Meet my octree world:

My end goal is to have this world destructible, and I am having an issue warping my head around how this can be done when you have LOD. The basic principle of LOD (as I understand it) is to collapse nodes that are further away from the camera (removing them from RAM completely), and divide nodes that are closer (allocating new memory in RAM), by doing this you only have X amount of memory allocated at once.
The issue arrives when you think about how to generate the LOD back after collapsing the tree. The only way I can think of is to use the same Noise function to sample the tree at the node you are dividing (like in the initial generation of the world) and use that to figure out how the children of the tree need to look.
But what happens when a user has modified that node beyond the Noise function? How can you collapse the tree and then divide it down again while restoring the user's modifications?
(Is the only way to keep separate track of all voxels changed by the user?)
That's all folks, thanks :)
(Language: C++)


texts: Help interpreting the physics of a rolling ball

texts:
I'm using this article for reference. I understand handling the collision aspect, but I can't figure out how to calculate the new velocity once the ball collides with the ramp. Without it the ball just slides down the slope and stops at the bottom, with no horizontal velocity generated from the descent.

The equation mentioned is

tangentialVelocity = velocity – (velocity * normal)normal

Which I've tried as

        ball.velocityX = _magnitude - (_magnitude * _normalX) * _normalX;
        ball.velocityY = _magnitude - (_magnitude * _normalY) * _normalY;

to no avail.

Here is what I've done so far, which finds how far the ball is intersecting in the ramp and moves it outside.

        var _distance:int = FP.distance(circleWorld.x, circleWorld.y, ball.x, ball.y);
        var _penetration:int = _distance + ball.radius - worldRadius;

        if (_penetration > 0)
        {
            var _componentX:int = circleWorld.x - ball.x;
            var _componentY:int = circleWorld.y - ball.y;

            var _normalX:Number = _componentX / _distance;
            var _normalY:Number = _componentY / _distance;

            ball.x += _normalX * _penetration;
            ball.y += _normalY * _penetration;
        }


texts: How to manually render with a given camera in Unreal Engine 4?

texts:
I would like to render with any camera at any given time for a Portal clone project.
There's a USceneCaptureComponent2D but it renders the whole scene to a texture.
I don't need to render the entire scene. I would like to setup stencils to avoid unnecessary rendering. I don't think this component supports this.
Additionally, I would like to render directly to the main framebuffer - without render textures, which this component uses.
Is it possible to do something like this in Unreal Engine 4?


texts:
I have two unity3d projects, both are using sprite renderers and sorting layers.
Project 1 has Following Sorting Layers:

Default
Tile Map
Items
Animals
UI
Particles

Project 2 has Following Sorting Layers:

Default
Background
Slots
Chips
Foreground
Map
UI

Project 1 is my main project. I need to merge these both projects. I created new layers in project 1 and then imported project 2 but sorting layers of project 2 are broken .Setting each layer again in project 2 is very difficult task and rework. How can i merge these two project without breaking any sorting layer or tags ?


texts: Networked projectiles in an authoritative server

texts:
I'm working on a multiplayer game, and I've implemented a simple enough player prediction (according to this great article) - which works well enough.

What isn't discussed there, and my question here; is how do I handle non-raycast projectiles (like missiles for example)?

There is RTT between the player pressing fire to the time he receives back the server's "confirmation", and then all other players add their latency to the mix.

And of course there is the issue of actually rendering hits; what if I see my missile hit someone in my simulation while he wasn't even there on the server and the missile missed him completely?

So my question is, what is the best way to hide latency for all players in (relatively) slow moving projectiles in an authoritative server?


texts:
I am looking to create a special kind of pathfinding system. At this point, the geometry is still flexible, but this pathfinding is integral to the project.

The goals I have are this:

I will have a number of entities seeking paths.
Each entity will have a memory of certain paths.
The memory will be based on landmarks. Landmarks will be objects or
entities on the map that can be or have been seen by the entity.
When an entity generates a path, it's only doing it based on what it
can see, and what it has memory of.  Anything else has to be
guessed, it can't use unknown information.
The system has to be able to handle a updating paths for a lot of
entities at once, but it never has to find the best path, especially
not on the first try.
It doesn't need to find a path to it's destination in a single
frame, just be able to make progress, and reach the target eventually if possible.
Entities might be able to share partial or full path information.

I'm thinking this is best served by some modified D* algorithm, but I was wondering if anyone had any other suggestions for something to do this, or challenges that I'd expect to face.

One thing I'm cognizant of for instance is that if I'm using landmarks to confirm the path, that I'll be able to quickly look up nearby landmarks.  If I have thousands of landmarks in a list and need to iterate through them and calculate distance to the player this is going to cause trouble.  If I'm going to define regions, like a convex hull, I might be able to share that calculation across entities when they need it since I might be able to say anyone inside this poly should be able to see everything within this poly.


texts: Minecraft - how do I add a PNG for a new Mob to either assets or resourcepacks

texts:
I've installed MCP and set up eclipse and successfully added my new monster to the game. It spawns properly and does everything I meant it to do. The only problem I still have is that the texture that I've indicated cannot be found. The game logs contains the following error:

java.io.FileNotFoundException: minecraft:textures/entity/spider/green_spider.png
       at net.minecraft.client.resources.FallbackResourceManager.getResource(FallbackResourceManager.java:51) ~[minecraft/:?]

I browsed various wikis and tuorials, some of which suggested that I need to add an asset folder to src/minecraft, but that didn't work. I found out that I could add my texture file to [mcp]/jars/resourcepacks/ but that didn't work either.

Can you tell me to configure resource pack loading or what to run in MCP to add my asset files to the game?


texts: How can I find a free or cheap redistributable font supporting runic characters?

texts:
I've been looking around for a font to include in my game which supports rune characters, specifically this Unicode block.

All the sites I go to don't demonstrate what Unicode characters that font contains, so I cannot gauge their usefulness for me.

I've been using the Segoe UI Symbol font, but it is only available on Win 7 & 8, and as far as I can tell, costs far too much to redistribute as part of a game.

Anyone know where I can go to find a font with my requirements?


texts: Can I use p/invoke in libraries loaded as assets in Unity Free?

texts:
I am interested in using utilising third-party libraries in Unity Free.

I know Unity can use managed libraries as assets, but only the Pro version supports using native libraries (DllImport within scripts). This thread, however suggests that it is possible to import DLLs in the free version.

I would like to utilise native libraries (as a hobbyist I cannot afford the Pro version), but want to do it the supported way so I don't have to worry about Unity 'fixing' this hole if that is what it is.

Is there any supported way to use native libraries with Unity free (in other words, is the method described in that thread using DllImport safe and reliable, or is it a workaround that might be patched away)?


texts: Is it possible to make realistic animations in 2D?

texts:
I plan to make a skateboarding game and I am wondering about one thing: is it possible to make 2D realistic animations to simulate skate's and skater's rotations or should I resort to 3D for realistic visual effects?

P.S: As you guess I am new to game development.


texts: Why are my Player Input Unity Events started twice?

texts:
I'm using the (new) "Input System" package and the "Player Input" component on my player prefab like this:

public class Player : MonoBehaviour
{
    [UsedImplicitly]
    public void Fire(InputAction.CallbackContext context)
    {
        if (!context.started) return;
        Debug.Log($"Fire!");
    }
}

The odd thing is, this method is invoked twice with context.started == true. What am I missing here? Why is the method invoked twice?
A minimal working example to reproduce the behaviour can be found on GitHub.
EDIT
The player joins automatically through the "Player Input Manager":


texts: Better texture downscaling at 9xMSAA than at 8xMSAA

texts:
I'm drawing my game on a render-to-texture FBO with multisampling. The multisampling works as expected, except for one thing:

No MSAA

8xMSAA

9xMSAA
(left is a untextured quad, right is a textured quad--the texture is much larger than the quad, the cross in the center of the texture is 2 line primitives)

As you can see, textures seem to suddenly have better downscaling at 9+ samples. Im trying to figure out why this is, because I'd prefer to have this quality of downscaling all the time (even if I'm at, say, 4 samples). The artefacting in the first two images is pretty ugly. I'm not using any mipmapping here, but I did try that as an alternative to this, and it does look much better. However, mipmapping looks a bit blurry compared to the third image, and is still not preferable in comparison.

This was rendered with an NVIDIA GeForce 980M, and it appeared to have the same behavior on other nvidia cards.


texts: Procedural mesh comes out black in any shader

texts:
I wrote a script that Creates a mesh procedurally
        mr = gameObject.AddComponent<MeshRenderer>();
        mf = gameObject.AddComponent<MeshFilter>();
        //
        mf.mesh = new Mesh
            {
                vertices = GetVertices(),
                triangles = GetTriangles()
                uvs = UpdateUVMap();
            };

        //assign material + shader.
        mr.sharedMaterial = new Material( Shader.Find("Shader Graphs/surface") );

(the mesh is a sphere for this example)
I created my Shader in shader-graph (any shader seems to have the same result)
When played, all seems good except that the object is black. What's happening?
//basic uv map example from docs
    public Vector2[] UpdateUVMap()
    {
        Vector2[] uv = new Vector2[this.vertices.Count];

        for (int i = 0; i < uv.Length; i++)
        {
            uv[i] = new Vector2(vertices[i].x, vertices[i].z);
        }

        return uvs.ToArray();

        //uvs.Clear();
        //uvs.AddRange(uv);
    }


texts: Are there copyrights for board game Risk and can I make the game, or similar, for mobile?

texts:
are there copyrights for board game Risk? It's popular and with lots of versions floating around, so I don't know if someone has rights or just for specific version. I'm not planning to make money with it, it would be a free game. If not, can I make something similar to that, and how much do I need to change it? I like the game a lot, it's for fun and learning purpose.
Thx in advance :)


texts:
Here's a pretty basic question:

My game supports custom keybindings. What label should I put on the button the player clicks to get to the menu that lets him customize them?

Specifically, this game is targeted at nerdy high-schoolers to nerdy middle-aged adults, and any given player may or may not be an experienced gamer, or even if they are they may or may not be familiar with first person shooters, where I imagine the idea of custom key bindings is usually first encountered.

I need a name that doesn't feel out of place in my menu (which consists of short two-word labels: "Start Game," "Load Game," "Level Select, "Save & Quit," etc...) but conveys the idea of "this is where you go to alter which buttons do what" without using semi-advanced gamer jargon like "bind" or "mapping."

Any suggestions?


texts: Handle vertex indicies in a vbo batch drawing call

texts:
I'm new in the OpenGL 2 world and want to render a lot of cubes (> 150.000).

How can I render such kind of cubes in practise?

My idea is to split the cubes to a set of vbo's (Maybe 2000 cubes per vbo).
Should I upload all cubes in one vbo or could I get a better performance with this approach?

Generally I have a problem, if I do a batch drawing call.
On design side, I want to add some structure to my code, so I want to work with object-oriented programming for my cubes. In time each cube is a object from the class cube.cpp. The class contains, among other things, the verticies for geometry, color and indicies.

My problem in oop is to manage the indicies for the verticies of each shape.
Has someone an idea to manage the indices?


texts: Seeking to streamline message system in my engine (C++)

texts:
So been building up my own custom engine, and one core bit of it is a message system to keep all the systems disconnected.

As it currently stands I have it take in a pointer to every other system, and then during their creation they register with the message system for what they want to receive.

The problem is the message system right now knows exactly what each system is, and I would like to simplify that.

My goal is to have any system sign up for messages, without the message system needing to care about the type of system. I thought about adding a "message class" parent class wrapper to put around every system, but that feels more like a jury rig then a fix, and I would like to avoid having layers of class wrappers.

Anyone have any thoughts how to simply this?


texts: URP cant get Pixel Perfect Camera to work

texts:
I am currently using URP to add bloom to my particlesystems. The problem im facing is that I cant pixelate the game. I have tried to implement several methods to post pixelate (via shaders and render texture) but none conserve the bloom on the particlesystem. This is the effect im after https://youtu.be/edaf2I-qwBg (using pixel perfect camera and zooming the editor window) but I cant achive this in build mode, any help on how I should pixelate the game so you can still see the character?

This is without 4x zoom:

This is my current settings:


texts: How to save a text file to relative Path

texts:
I'm creating an app that should be accessable from every platform (android, IOS, windows).
At this moment I'm saving a file that is set to a specific path.
c:\test\test.exe. Now I know that Android and IOS don't have such directory.
I was wondering if it was possible to save the file to a relative path?
If not I might have to adapt the code that checks on what kind of device the app is running

psuedocode:

If runningOnWindowsOS
 writefile(c:\test\test.txt)

if runningOnAndroid
 writefile(NOCLUE)

If runningOnIOS
 writefile(NOCLUEEITHER)

this is my code at the moment:

        string path = @"C:\test\test.txt";

        string createText = txt3.text + txtToLog + System.Environment.NewLine;

        File.WriteAllText(path, createText);

any clues on how to proceed with this


texts:
In the Unreal Engine docs, it is mentioned that, in order to create a Animation Sequence using the Control Rig, it is possible to create a ControlRig Sequence.
Now, why do I need that?
I need it to create Animation Sequences for my character and I do not want to create the Animation Sequence in other softwares, like Blender.
So why I can not find  ControlRig Sequence in UE4 menus?


texts: MonoGame: Music does not stop playing upon exit of game

texts:
I use MediaPlayer to play the background music. Sometimes, the music does not stop playing when I exit the game. This is even though I use the following code:

    protected override void OnExiting(Object sender, EventArgs args)
    {
        base.OnExiting(sender, args);

        MediaPlayer.Stop();
    }

What is wrong?


texts: Unity - Instantiate GameObject from client on Network

texts:
I am building a game where a weapon shoots prefab bullets. I am trying to make this a multiplayer game, so the bullets need to be spawned into the Network.

What happens right now is that if I shoot a bullet from a host, the bullet is shot, but doesn't appear on the client screen. If I shoot the bullet from the client, the bullet doesn't appear on either screen. In fact, the function CmdShoot() isn't even called, as the Debug.Log("Hello") is not called. Here is the current code:

public class Gun : MonoBehaviour
{

    private GameObject bulletPrefab;

    void Update()
    {
        if (Input.GetMouseButtonDown(0)) {
            owner.GetComponent<PlayerSetup>().CmdShoot(bulletPrefab, transform.position, owner.name, GetComponentInParent<Weapon>().angle);
        }
    }
}

public class PlayerSetup : NetworkBehaviour
{

    void Start ()
    {
        // Disable components if not local player
    }

    [Command]
    public void CmdShoot(GameObject bulletPrefab, Vector3 position, string playerName, float angle)
    {
        Debug.Log("Hello");
        GameObject bullet = Instantiate(bulletPrefab, position, Quaternion.identity);
        bullet.name = "bullet: " + playerName;
        bullet.GetComponent<Rigidbody>().AddForce(Quaternion.AngleAxis(angle, Vector3.forward) * Vector3.right * bulletPrefab.GetComponent<Bullet>().force);
        Destroy(bullet, 10f);
        NetworkServer.Spawn(bullet);
    }
}

Edit:

This piece of code doesn't work either, gives the same result. No error, but the function is also not called. The Input is detected though:

    void Update() {
        if (Input.GetMouseButtonDown(0)) {
            CmdShoot();
        }
    }

    [Command]
    void CmdShoot()
    {
        Debug.Log("Shoot");
        GameObject bullet = Instantiate(gunComponent.bulletPrefab, gun.position, Quaternion.identity);
        bullet.name = "bullet: " + transform.name;
        bullet.GetComponent<Rigidbody>().AddForce(Quaternion.AngleAxis(GetComponentInChildren<Weapon>().angle, Vector3.forward) * Vector3.right * gunComponent.bulletPrefab.GetComponent<Bullet>().force);
        Destroy(bullet, 10f);
        NetworkServer.Spawn(bullet);
    }

```


texts: LibGDX with GWT ignore source file changes

texts:
I'm using LibGDX with GWT to create a web version of an app that runs without problems on the desktop, Android and iOS. However, the HTML version of the app had a few problems with constructs unsupported by GWT. I've fixed these issues and I get a proper HTML/GWT app that I can start within my browser.

However, I found some additional problems and I've fixed the first one but the changes are ignored by the GWT compiler: I still get the same error. This is when using Eclipse but also when doing stuff via the Windows command prompt.

I've tried the following:

Cleared the browser cache (Chrome, Firefox won't run but that's a different problem)
Removed all Gradle cache files from my home directory
Removed all generated files (gradlew.bat clean)
Re-imported the project in Eclipse
Rebuild the Gradle model in Eclipse
Use the "Dev Mode On" bookmarklet to force development mode
Use the "Dev Mode Off" bookmarklet to force release mode

In all cases the web app still fails to run properly and I get the same error in the JavaScript console.

Any suggestions on how to proceed here?


texts: How to securely retrieve game stats from clients in a p2p game network?

texts:
I'm working on a P2P game and I know I should never trust the clients. I my architecture, there is a "Master Server" that stores game room (host) informations. Players can create their own rooms (hosting) and play with together.

There is another server that is "Info Server", it stores character informations like inventory, level etc. Now, I need to make a stats table with kills/deaths and I have to get these kill/death events from host player (host player >> [event] >> master server). But I think host player can send a lot of kill events because it is authoritative, so master server will process/handle all events from the host player.

How can I trust these events? Can't a server just send fake kill/death events?


texts: Why is the Set new visibility doesn't resets the hair's skeletal mesh visibility to be visible?

texts:
The helmet is loaded when pressed a defined key and helmet is removed automatically by setting the remove on 2s delay.
The Problem when the helmet is removed, the hairs visibility doesn't sets to be visible while blueprint is set to restore the visibility.
setvisibility and sethiddeningame both are tested, none of them works.
How to fix it? any help appreciated.


texts:
In Unity, how can I programmatically make a shape like:

The gaps in the shape will all be the same size but their number may vary.


texts:
How do I fix my code?

At the moment my character goes up for as long as you hold the up key.  I want a more jump like effect where the character will drop back down when it reaches a certain height.  I want the character to only be able to jump again once it's fallen back down.

Below is my code so far.

var canvas = document.getElementById("mainCanvas");
var context = canvas.getContext("2d");

var keys = [];

var width = 500, height = 400, speed = 4;

var score = 0;

var player = {
        x: 40,
        y: 350,
        width: 20,
        height: 20,
        gravity: 20,
        weight: 1
    };

window.addEventListener("keydown", function(e){
        keys[e.keyCode] = true;
    }, false);

window.addEventListener("keyup", function(e){
        delete keys[e.keyCode];
    }, false);

function game(){
    update();
    render();
}

function update(){
    if(keys[38]) player.y-=speed;

    if(speed < player.gravity) player.y+=player.weight;

    if(player.x < 0) player.x = 0;
    if(player.y < 0) player.y = 0;
    if(player.x >= width - player.width) player.x = width - player.width;
    if(player.y >= height - player.height) player.y = height - player.height;
}

function render(){
    context.clearRect(0,0,width,height);

    context.fillStyle = "blue";
    context.fillRect(player.x, player.y, player.width, player.height);

    setInterval(function(){
            game();
        }, 1000/60)
}


texts:
I've just started to learn Unreal Engine 4.26.2 while developing an Atari Pong clone.
This is how I have implemented the Paddle's movement (but this implementation doesn't accelerate or has inertia):
// Called to bind functionality to input
void APaddle::SetupPlayerInputComponent(UInputComponent* PlayerInputComponent)
{
    Super::SetupPlayerInputComponent(PlayerInputComponent);

    // Respond every frame to the values of our movement.
    InputComponent->BindAxis(TEXT("MovePaddle"), this, &APaddle::Move_ZAxis);
}

void APaddle::Move_ZAxis(float AxisValue)
{
    CurrentVelocity.Z = FMath::Clamp(AxisValue, -1.0f, 1.0f) * 100.0f;
}

But I want to do two things:

While the user is pressing the key the paddle movement will accelerate.

When the user release the key the Paddle won't stop immediately; instead, it will slowing down until it stops.

Is there anything done with Physics that I can use here or do I have to implement it by myself?
By the way, I'm not English and I don't know if inertia is the right word here.


texts: How to properly do smooth speed degradation?

texts:
at the moment I'm using this:

playerclass.xspeed += (playerclass.xvelocity * loopclock.getElapsedTime().asSeconds());
to build up speed

To ramp up speed

and this:

if (playerclass.xspeed > 0||(playerclass.xspeed < 0)){playerclass.xspeed *= (1-loopclock.restart().asSeconds());}

To degrade it.

It looks pretty smooth to me but the speed will never reach zero, just get smaller and smaller infinitely

Setting the speed to zero if it's ever below a certain bound doesn't work because my speed builds up in very small amounts.

New to programming so apologies if this is an obvious answer.


texts: Is there a plugin example for SKSE Special Edition?

texts:
I'm having trouble creating a skse plugin for skyrim special edition.
For the old version there is a example plugin: https://github.com/xanderdunn/skaar/releases/tag/plugin3

I've tried to do it by

Opening the skse64.sln file.
Adding a new project for the plugin example
Copied the sources from the old plugin example.
Added references to the other projects ("skse_common" and "common_vc14").
Corrected includes for the new version.

Everything compiles except for this line:

registry->RegisterFunction(
                      new NativeFunction0 <StaticFunctionTag, float>("MyTest", "MyPluginScript", PluginExample::MyTest, registry));

MyTest (for completeness):

float MyTest(StaticFunctionTag *base) {
   _MESSAGE("MyTest() will return %f", 3.3);
   return 3.3;
}

This is the exact code from the example from skse for oldrim, but I get the following compile errors from this line:

4>PluginExample.obj : error LNK2019: unresolved external symbol "void * __cdecl Heap_Allocate(unsigned __int64)" (?Heap_Allocate@@YAPEAX_K@Z) referenced in function "public: static void * __cdecl NativeFunctionBase::operator new(unsigned __int64)" (??2NativeFunctionBase@@SAPEAX_K@Z)
4>PluginExample.obj : error LNK2019: unresolved external symbol "void __cdecl Heap_Free(void *)" (?Heap_Free@@YAXPEAX@Z) referenced in function "public: static void __cdecl NativeFunctionBase::operator delete(void *)" (??3NativeFunctionBase@@SAXPEAX@Z)
4>PluginExample.obj : error LNK2019: unresolved external symbol "public: __cdecl StringCache::Ref::Ref(void)" (??0Ref@StringCache@@QEAA@XZ) referenced in function "public: __cdecl NativeFunctionBase::NativeFunctionBase(void)" (??0NativeFunctionBase@@QEAA@XZ)
4>PluginExample.obj : error LNK2019: unresolved external symbol "void __cdecl PackValue<float>(class VMValue *,float *,class VMClassRegistry *)" (??$PackValue@M@@YAXPEAVVMValue@@PEAMPEAVVMClassRegistry@@@Z) referenced in function "public: virtual bool __cdecl NativeFunction0<struct StaticFunctionTag,float>::Run(class VMValue *,class VMClassRegistry *,unsigned long,class VMValue *,class VMState *)" (?Run@?$NativeFunction0@UStaticFunctionTag@@M@@UEAA_NPEAVVMValue@@PEAVVMClassRegistry@@K0PEAVVMState@@@Z)
4>PluginExample.obj : error LNK2019: unresolved external symbol "void * __cdecl UnpackHandle(class VMValue *,unsigned long)" (?UnpackHandle@@YAPEAXPEAVVMValue@@K@Z) referenced in function "void __cdecl UnpackValue<struct StaticFunctionTag>(struct StaticFunctionTag * *,class VMValue *)" (??$UnpackValue@UStaticFunctionTag@@@@YAXPEAPEAUStaticFunctionTag@@PEAVVMValue@@@Z)
4>PluginExample.obj : error LNK2019: unresolved external symbol "unsigned __int64 __cdecl GetTypeID<float>(class VMClassRegistry *)" (??$GetTypeID@M@@YA_KPEAVVMClassRegistry@@@Z) referenced in function "public: void __cdecl NativeFunction0<struct StaticFunctionTag,float>::InitParams(class VMClassRegistry *)" (?InitParams@?$NativeFunction0@UStaticFunctionTag@@M@@QEAAXPEAVVMClassRegistry@@@Z)
4>PluginExample.obj : error LNK2019: unresolved external symbol "public: void __cdecl NativeFunction::DebugRunHook(class VMValue *,class VMClassRegistry *,unsigned long,class VMValue *,class VMState *)" (?DebugRunHook@NativeFunction@@QEAAXPEAVVMValue@@PEAVVMClassRegistry@@K0PEAVVMState@@@Z) referenced in function "public: virtual bool __cdecl NativeFunction0<struct StaticFunctionTag,float>::Run(class VMValue *,class VMClassRegistry *,unsigned long,class VMValue *,class VMState *)" (?Run@?$NativeFunction0@UStaticFunctionTag@@M@@UEAA_NPEAVVMValue@@PEAVVMClassRegistry@@K0PEAVVMState@@@Z)
4><MyPath...>\src\skse64\x64\Debug\example_plugin.dll : fatal error LNK1120: 7 unresolved externals

Questions:
Can someone provide a simple VS solution, which does what the plugin example for skse oldrim did or explain what I'm doing wrong?


texts: Why is my client's body drifting even after using data from the server, and how do I fix it?

texts:
I am trying to use Box2d on nodejs server with libGDX client. What I am trying to apply is authoritative server model so clients are just sending input data to server, server is running simulation and returning data to clients.

Client sends right key pressed input data to server, server calculates applyForce vector, applies force to server side body.

Server is sending world's body data to clients such as linearVelocity, position angular velocity etc with sendWorldData() function. After geting data, clients equalize this data to client side bodies.

Right now I just equalize linear velocity data, if I use setTransform on body for same position, it breaks the simulation and game crashes. I guess just linear velocity is way to go for now.

The problem is: even though I return the same linearvelocity from server to client, bodies end up on slightly different x,y positions.

client is
(6.8612046,7.3647866)
server is
(7.260152142360204,7.807573379341183)

I read a lot about this problem and started by trying to fix timestep on server and client.
Client timestep:

private var fixedTimestepAccumulator = 0f
    private var MAX_ACCUMULATED_TIME = 1.0f
    val TIMESTEP = 1 / 60f
  fun update(delta:Float){
        fixedTimestepAccumulator += delta;
        if(fixedTimestepAccumulator > MAX_ACCUMULATED_TIME)
            fixedTimestepAccumulator = MAX_ACCUMULATED_TIME;

        while (fixedTimestepAccumulator >= TIMESTEP) {

            world.step(TIMESTEP, 6, 2);

            fixedTimestepAccumulator -= TIMESTEP;
        }

        inputUpdate(delta)
        cameraUpdate(delta)
        tmr.setView(camera)
        batch.projectionMatrix.set(camera.combined)

    }

Server update method:

var lastUpdate = Date.now()/1000;
var fixedTimestepAccumulator = 0;
var MAX_ACCUMULATED_TIME = 1;
var TIMESTEP = 1/60;

function physics_hanlder() {

    var now = Date.now() / 1000;
    var delta = now - lastUpdate;
    lastUpdate = now;
    fixedTimestepAccumulator = fixedTimestepAccumulator+delta;
    if(fixedTimestepAccumulator > MAX_ACCUMULATED_TIME)
        fixedTimestepAccumulator = MAX_ACCUMULATED_TIME;

    while (fixedTimestepAccumulator >= TIMESTEP) {
        world.step(TIMESTEP,6,2);
        sendWorldData() // sends servers body data to clients
        fixedTimestepAccumulator -= TIMESTEP;
    }

}

setInterval(physics_hanlder, 1000/60);


texts: How to move in between grid in crossword game

texts:
I am trying to create crossword game in my current app. As my current project is in iOS native so I wanted to implement this game only in UIKit so that it can be easily integrated.

Requirement

i need these types of movement in the crossword(as shown in below gif), like whenever I entered any char, it automatically moved to the next grid and when I entered the backspace button it clear that grid and automatically moves the previous grid.

Issue

Right now user have to select each and every grid to give input, which reduces the user interaction. So I wanted to implement this movement so that user can use crossword in a better way.

What I have done?

I successfully created the UI part by using the json structure which is similar to iPuz. But facing issue to implement this movement in crossword.

To check screen ui image, json structure & git repository, pls cleck here, if you need any further information pls ask in comment I will update the question.


texts:
I'm trying to understand how LibGDX handles screen size / resolution, etc.
Coming from XNA this seems very confusing to me. Basically I want to support 480x800 for my game. If the screen size is different it should scale the resolution and use letterboxing. To do this I use a FitViewport. And that's the code:

public static final int VIRTUAL_WIDTH = 480;
public static final int VIRTUAL_HEIGHT = 800;
Viewport viewport;
SpriteBatch spriteBatch;
ShapeRenderer shapeBatch;
Texture img;

@Override
public void create()
{
    viewport = new FitViewport(VIRTUAL_WIDTH, VIRTUAL_HEIGHT);
    spriteBatch = new SpriteBatch();
    shapeBatch = new ShapeRenderer();
    img = new Texture("test.jpg");
}

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

@Override
public void render()
{
    Gdx.gl.glClearColor(0, 0, 0, 1);
    Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);

    shapeBatch.begin(ShapeType.Filled);
    shapeBatch.setColor(Color.GRAY);
    shapeBatch.rect(0, 0, viewport.getWorldWidth(), viewport.getWorldHeight());
    shapeBatch.end();

    spriteBatch.begin();
    spriteBatch.draw(img, 0, 0);
    spriteBatch.end();
}

Now if I set the game resolution to be 480x800 right at the beginning, it basically works except that if I change the window size, the resolution keeps to be 480x800. So it stretches the image but keeps the aspect ratio:

And if I run the game with any other resolution like for example 700x500 I get this:

What is going on behind the scenes?
(And sorry if my english is bad)


texts:
How can i achieve transparency and shadowing for a model in XNA ? Do you have a good tutorial ?

For the shadow i can manage the effect but how can i implement the transparency also ? Do i have to use the pass in effects ? And if so, how can i make an object transparent ?


texts: How to save and restore Bullet Physics state?

texts:
I'm looking for information on how to save the runtime state of rigid bodies with Bullet Physics. Most of my world consists of static objects, but I have a few dynamic and kinematic objects as well. I need to take a snapshot of the game state and later restore the exact same state so that it produces the same simulation as if there wasn't any pause. I can easily (and prefer to) recreate the whole world including the rigid bodies, their configuration, collision shapes and constraints.

In addition I need to reset the objects to their initial state, but I think solving the save/restore problem also solves resetting.

I'm using JBullet, which is based on Bullet version 2.72. This means that the built-in serialization is not available for me, as it was added in version 2.76. However answers utilizing the serialization are also welcome, as Java has built-in serialization and others might find it useful. However the description on the wiki page sounds like it's meant for storing whole worlds instead of just the runtime state.

Checking the source code of RigidBody and CollisionObject reveals lots of internal non-final fields of which many are pointers instead primitives. I don't know which of the fields I should save and how to handle the non-primitive fields.

I am surprised to not having found any information on the Internet about this, as I think this is necessary for any game using Bullet physics and requiring exact save and restore functionality. I would prefer a solution that requires only the public API, but I'm open to other solutions as well including modifying the source code as a last resort. I'm also aware of the differences on floating point operations between platforms, but that is not a concern for me.

Edit:

I implemented the solution suggested by Byte56. I'm now saving and restoring worldTransform, linearVelocity and angularVelocity. I also tried motionState, but that did not have any effect. After restoring the state my object seems to continue the correct trajectory until first collision with a (static) wall. After the collision the object doesn't follow the same path anymore. Interestingly there seems to be only 5-7 slightly different paths that the object randomly chooses.

Without the save and restore my simulation is completely deterministic and always proceeds exactly the same results when running multiple times with the same starting values.

I was thinking that the randomness could have been because of uneven number of simulation steps. I'm using frame skipping and passing 1.0 / 60 as the delta time for stepSimulation: dynamicsWorld.stepSimulation(deltaTime, 100, 1.0f / 200);. I tried changing 200 to 180, but that didn't help. I wonder if there is something in the DiscreteDynamicsWorld that I should also save. I also tried to save DiscreteDynamicsWorld.localTime through reflection, but no luck.

Edit2:

After closer investigation even the initial trajectory before any collisions is slightly off. However there seems to be only a constant offset in the coordinates and after the first collision the path changes direction compared to the original.

I implemented a custom serializer using Java Reflection API, which recursively stores all primitive fields from RigidBody and DiscreteDynamicsWorld. That didn't help. I also tried changing physics updating to just dynamicsWorld.stepSimulation(1.0f / 60.0f);, but no luck there either. Now I'm out of ideas how to proceed.


texts: Change the min width/height of a LayoutElement to scale with the screen size

texts:
I want to change the Min Width and Min Height configured in my LayoutElement so that they scale proportionate to the screen size.
For example, at a screen resolution of 1920x1080, the min width is 300. Then if I reduce my screen size to 1280x720 (one-third smaller), then the min width should become 200.

How can I do this?


texts: Set up UnityEvent in script with string method name?

texts:
I'm making a game that I'd like to be data driven. I've got a designer that can make levels using unity and saving them as a unity scene. What we're doing is exporting those levels as XML and loading them from a website into a single scene. This allows for rapid prototyping on devices; the designer does not need to wait for me to push builds out or push his own out.

Many of the scripts on the prefabs we're loading use UnityEvents, so I can allow my designer to trigger anything he wants in a given script. It gives him more freedom to design and stops my scripts from being too specific.

Currently, I'm reducing these UnityEvents down to the object they are referencing and the function they are calling and storing them as string attributes in the XML. However, I'm unsure how to convert from the string function name into an actual function pointer for the UnityEvent, nor do I know how to set up a UnityEvent the way the inspector allows me to. See here you can attach an object and select a function to trigger, then simply call Invoke() on the UnityEvent, but the only documentation I can find on UnityEvent scripting only allows you to add listeners with methods within the script.

Here I am getting the Type from a string and the MethodInfo from a string, but am unsure of how to set up the UnityEvent with this information

Type type = Type.GetType("ScriptName");
MethodInfo theMethod = type.GetMethod("FunctionName");
UnityEvent myEvent = new UnityEvent();
myEvent.AddListener(); //Reference to Method goes here
//reference to the script goes where?