Tag Info

New answers tagged

0

This was apparently a known issue in the Box2D plugin. As much as I hate suggesting buying a library like this, they claim to have fixed this bug in the currently distributed version. If you're dead set on Phaser and this Box2D plugin, I would consider buying it but my honest advice would be to stay away from such libraries.


0

Fixed by changing my C# script: private delegate string ReadData(); private ReadData dataReader; #if UNITY_WEBGL && !UNITY_EDITOR [System.Runtime.InteropServices.DllImport("__Internal")] private static extern string ReadFromDom(); #else public TextAsset testData; private string ReadTestData() { return testData.text; } #endif void Awake() { ...


0

Unity doesn't support threads. You can use C# threads for some native .NET code but the Unity API is not thread-safe. http://answers.unity3d.com/questions/180243/threading-in-unity.html


1

I solved it! A friend of mine told me it's pretty standard if the material is not set to doublesided. (Or I could make a billboard out of it). But in code I had to add mat.side = Three.DoubleSide; Sorry guys for bothering you with this - it was probably quite basic but I'll leave it on just in case someone else encounters this problem!


1

To make it easier for you to switch between world coordinates and grid coordinates, you should make two functions, projectToWorld and projectToGrid. pseudo code: /** * returns the topleft position of a given grid coordinate. */ function projectToWorld(gridX, gridY) { return new Vector2(TILE_WIDTH * gridY, TILE_HEIGHT * gridY); } /** * ...


0

I think the trick here is that a lot of cards have the same kind of effects with some variations while some cards have totally unique effects. Imo, what you should do is to do this. This is written in typescript, but you can get the idea. class Effect extends { static fromArray(game, card, data) { if (data.type == "SelfDestructEffect") { ...


0

Consider adding scripting to your game. Then you can store code snippets in the scripting language in the cards themselves. That will give you a lot of flexibility. This could, for example, look like this: { "name": "Ocean Humans", "type": "Creature", "description": "When Ocean Humans dies, you lose half of your hit points" "components": { ...


1

You don't necessarily need a parabola formula for this. The best way, in my opinion, to do this is to update the velocity of the ball each frame. I don't know how you organized your code, but I assume you have an update function that is executed multiples times per frame. To make the trajectory of a parabola, you simply need to substract a constant to the ...


4

You can Destroy the component. Be careful about which object you destroy, though. If you pass a GameObject to Destroy, you will destroy the entire thing. To destroy the component, you must pass a reference to that component specifically. //example: destroys the MeshRenderer attached to this GameObject var sphereMesh = GetComponent(MeshRenderer); ...


1

Hey there are couple of things which you are missing out. 1) Even thought the motion is in 2d plane but the gameobject dimension is 3D, so use Vector3 instead of Vector2 2) When you calculate Vector3 Movetowards it returns a value which is calculated upon current position , target position and speed. This needs to be assigned to the transform of the AI. ...


0

Your targetX and targetY are being set as your current script's transform.position, rather than your target's position. Also, targetX and targetY are Transforms, when really it sounds like they should be floats, or perhaps even just simplified as a single var target : Transform;. You could also just have var me : Transform; as well. Your MoveTowards should ...


1

Make sure that "Is Kinematic" option for rigidbody in the inspector is off. Here is a very basic example for adding torque. var torque: float; var rigidBody: Rigidbody2D; function Start() { torque = 20; rigidBody = GetComponent.<Rigidbody2D>(); } function FixedUpdate() { rigidBody.AddTorque(Time.deltaTime*torque); } Time.delta time ...


1

As Vector2 is a type composed by two numbers which are x and y, then you should be able to get the position by asking both numbers: Vector2 YourVar; YourVar.x; YourVar.y; So you should use something like: SetPositionToMove(YourVar.x,YourVar.y); //if the functions expect x and y or: SetPositionToMove(Point2(YourVar.x,YourVar.y)); //if it expects a ...


0

Another option may be using a quadtree structure or if you have many moving objects a spatial hashing aproach.


1

Refactoring is your friend !!! Separate the issues and try to get your code as generic as possible. Separate and factorise the steps of the computing. Keep comments short. • Boilerplate : // ------------------------ var g = 9.81; //Gravitational acceleration var v = 35.9; //Experimantally measured arrow speed var sqrt = Math.sqrt, atan2 = ...


0

As pixelmike mentioned, the problem might be that the keydown event executes every x milliseconds while the key is being pressed, and that is what produces the wrong player.facing value. Since you want the player to move in only one direction, the one of the last key pressed (and I guess that you set player.moving.x = false somewhere because the movement ...


2

EDIT (added short steps): get triangle normal vector v1 (normalized) get reference surface normal vector v2 (normalized) get angle between normals : angle = acos(v1•v2) (where • = 'dot' product ) get slope = Tan(angle) if you need a surface normal here come the simple algoritm : A surface normal for a triangle can be calculated by taking the vector ...


2

One way to apply light effects with the Context2D is to use the composite operation 'lighter' (globalCompositeOperation='ligther'), and adjust the alpha (globalAlpha= 0.0 to 1.0). Then you can either : • Draw the shape of the light with several geometric drawings that create a simple shade to get a cartoonish light effect. • Define gradients to get a ...


0

Here's what the jQuery documentation says: All animated properties should be animated to a single numeric value, except as noted below; most properties that are non-numeric cannot be animated using basic jQuery functionality (For example, width, height, or left can be animated but background-color cannot be, unless the jQuery.Color plugin is used). You ...


0

For anyone else in this dilemma, I would recommend these links to you: https://www.codeandweb.com/texturepacker/tutorials?km_user-type=developer https://www.codeandweb.com/texturepacker/download


2

Since javascript is a scripting language, updating it wouldn't be a big deal, it would mean restarting the server, but it would seem most online games go through some sort of restart when introducing new things anyways. You really don't want this. Yes, some items will need reboots, because they'll need new accompanying game logic. Minor updates, ...


3

Rather than hard-coding your data in Javascript, why not use JSON. It's always a good idea to separate your data from your program, and splitting out item definitions into JSON files would be very clean I think. Node even let's you use "require" with JSON files, how handy: How to parse JSON with node Databases are a great technology to learn if you haven't ...


0

To prevent the check of the object colliding against itself, just check the reference like so: Core.objectCollision = function() { if (Core.Mouse.isHolding != null) { for (i in Core.Objects) { // Skip the object that was grabbed. if (i == Core.Mouse.isHolding) continue; if ...


0

Note the following important identity for augmented isometric affine matrices: where the isometric condition is recognized from: and is the translation in world coordinates of your original transformation. In vector terms, if you think of your original transformation as being then the inverse transformation, to return to World Coordinates is ...


0

Look in pixi.js/src/filters or try pixi-extra-filters/src/filters/glow. fireball.filters = [ new PIXI.filters.GlowFilter(viewWidth, viewHeight, distance, outerStrength, innerStrength, color, quality) ];


0

I wasen't able to get the array working so I bypassed it and got it working by adding contextVar.strokeRect(filledCircle.x,filledCircle.y,filledCircle.w,filledCircle.h); to the addFilledCircleFunc. // to do: // add gameloop and draw with gameloop? // stroke line in resize fix // collission check + detection objects // functions to draw detection objects // ...



Top 50 recent answers are included