New answers tagged

0

I would recomend you to refactor your code in a more modular way, i did once a ScenesManager module, give it a peek.


0

The whole setup seems a bit strange. Is the speed always a fixed number, and what you're dealing with now is how to choose direction? Or is the speed dependent on the movement as well? If the latter case (speed dependent on mouse movement): You should either make this "physical", i.e let the delta mouse movement result in acceleration, or link delta ...


0

You could add a trigger to the plane and then write a script to check, if an object with a tag "Player" is inside it (don't forget to set the players tag to "Player") . Make the speed variable in the player movement script to public so that other scripts can access it. Then when the player is in trigger set the speed variable higher, and when ever the player ...


0

Organise your units in areas. An area can be a section in your grid (1 There are various implementations of quadtrees (Google is your friend). This way a unit only has to iterate through the enemy units that are in neighboring quadtree spaces (or quadtree spaces within range of said unit). This greatly speeds up the targetting/moving scenario's as each ...


2

First , your polarToComponent(magnitude, angle) { return { x: magnitude * Math.cos(angle), y: magnitude * Math.sin(angle) }; Called for each ball at start time, introduce a numeric error. So you must calculate the total velocity before starting simulation and compare with that instead of 30. Second your function checkCollisions() ...


0

What you need to do is to calculate the normal of the collision then reflect the impact vel across the collision normal: // r = v - 2 * dot(v, n) * n; r = result vel, v = impact vel, n = normal of collision.


1

The gist of CCD is really nothing dazzling. Here's the description of a serial set-up (a chain of links and joints) you have an assembly of N joints and N links the first joint is called the root joint and has index 0 joint i defines the frame where the rigid body for link i has its geometry described in (it's easier since people usually select a local ...


0

All Phaser display objects (group, sprites...) are based on PIXI ones. PIXI objects can be rendered in phaser render tree. the only problem is the update and postUpdate function. I solved it adding this simple patch: PIXI.DisplayObject.prototype.update = function () { }; PIXI.DisplayObject.prototype.postUpdate = function () { }; this patch adds a empty ...


1

Nothing in this code snippet makes a distinction between this tree vs. the tree the player is looking at. Unless that's what Camera_script.tree is supposed to do, but at long as that variable isn't null, the if-check will be true. I think what you want there is Camera_script.tree == this.tree


1

In Javascript, a property can also be a function. Don't make enemyType a string. Make it an object which has multiple methods for different interactions. violetThing = { name: "violet", sprite: "violetThing.png", onTouchFunction: setMagnetic, color: '#ffdd22' } yellowThing = { name: "yellow", sprite: "yellowThing.png", ...



Top 50 recent answers are included