Search the Community

Showing results for tags 'ai'.

More search options

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


  • HTML5 Game Coding
    • News
    • Game Showcase
    • Coding and Game Design
  • Frameworks
    • Phaser 3
    • Phaser 2
    • Pixi.js
    • Babylon.js
    • Panda 2
    • melonJS
    • Haxe JS
    • Kiwi.js
  • General
    • General Talk
  • Business
    • Collaborations (un-paid)
    • Jobs (Hiring and Freelance)
    • Services Offered

Found 22 results

  1. Hi, I've gone through the stuff on skeleton animations on the babylon docs, virtually all examples involve some form of scene.registerBeforeRender or scene.registerAfterRender stuff. I would like to make an humanoid character, say, pathfind and start walking from A and then stopping automatically at B. So, the usual way to do it in C# or other languages is to have the character be at rest pose at A, blend into walk pose and then blend into rest pose at B with the waypoints given. I found that babylon scene.registerBefore/AfterRender calls will not run when the browser tab is not active. So I could have my AI start walking, tab out and then to tab back after a few minutes to find that it hadn't left Point A yet. I'm new to animating characters on the web and tried to solve it in the PG (with the dude) but can't seem to animate his position without pausing when browser tab is not active. How should I go about solving this issue ?
  2. Hello Everyone, I've been trying to go at this on my own but I've been stuck for days trying to add some basic AI to a cube. Play the FPS style game here on desktop or mobile: you can find the full JavaScript here: Controls: touch the cube button on the bottom to shoot ice cubes and use standard universal camera controls to move and look around. Here's where I'm stuck: I got window.cube to jump and look at the camera but now I need a force to push the window.cube to move towards I just can't figure out how to setLinearVelocity in the local forward direction of window.cube. redMesh is the Mesh of window.cube and redCube is the impostor of redMesh. (Also would be nice if the lookAt() rotation was eased or slowed down so it wouldn't seem so sudden but that's a lower priority.) Here's the part of the code that controls the cube AI and thanks in advance for taking a shot at this! // Global Scope Declarations for Console Tests window.button = button; window.cube = redCube; window.cubeMesh = redMesh; = camera; // Red Cube turns to look at camera const rotateCube = function rotateCube() { redMesh.lookAt(camera.position); }; // Cube Movement towards Camera ??? const jump = new BABYLON.Vector3(0, 5, 0); const front = new BABYLON.Vector3(0, -10, 0); const goForward = redMesh.getDirection(front); const moveCube = function moveCube() { redCube.setLinearVelocity(jump); rotateCube(); // redCube.setLinearVelocity(goForward); }; window.setInterval(moveCube, 2000);
  3. Video: YouTube Update: Big thanks to Freank from who helped me completely rework the graphics! Let me know what you think! I think it makes a big difference. Also, local multiplayer was added. Hello HTML5GameDevs! is back with another game after a long time! This time with a puzzle/strategy game. I recently got second place in a rather large AI programming challenge, and I decided to make a game out of the challenge! I did have to dumb down the bot so it is beatable though. Let me know what you think! Play Here: Tower Capture
  4. Twitter - Subreddit - Dev Blog - Discord Hello my name is Sam, I'm also the lead artist for Super Combat Squadron. We're a small indie dev team trying to put out a lightweight browser RTS. It's been just myself and one other programmer been developing the game for about a year now but, due to unforeseen circumstances, the lead programmer has had to take a step away from the project for personal reasons. I'm still in contact with him for help in the transitionary period but I'm looking to replace him on the team with some new programmers. Currently we just completed our first internal playtest and got some good feedback from that, and the roadmap for the future was to push towards the first public demo, and then if the feedback looks good and things work out, were considering running a Kickstarter or other crowdfunding attempt to get the funding to take the game further. The ideal skill set we're looking for would include: Phaser and JavaScript (goes without saying). A previous title or some example of your work with Phaser. Possessing a strong focus on: Networking Pathfinding AI Loves and plays RTS or MOBA games a bonus. Your position in all this would be helping tackle some bugs and featured we identified and fixing some issues blocking a public demo release. We're trying to cut the fat and make it purely a bee-line to public demo release. As previously mentioned, I'd love for it to transition into a longstanding paying role through crowdfunding, worst case scenario we stop at public demo release if the interest just isn't there. If you are interested, you can contact me here, or at our email address:
  5. enemy AI when using tilemap

    How would I create basic enemy AI (say, have a guard patrol and when he hits a wall he turns around) when using tilemaps? I tried using the blocked property but that didn't seem to work.
  6. Hello everyone, I'm developing an AI-focused book for Phaser similar to this one, but a shorter (more like a Handbook, instead). However, some of the techniques and patterns that Phaser makes me use have given me the idea of probably expanding and improving these ideas and convert them into a Plug-in, or work directly on the Phaser repository in order to have a basic AI module similar to arcade physics in terms of scope (keep things really simple, yet functional and friendly to developers). Would you be interested in supporting this work via IndieGoGo? If so, would you rather have the book, the component, both? I was thinking in working on the Phaser AI module as a stretch goal from the book, so later the whole community can benefit from it. Looking forward to hearing from you.
  7. P2 Space Shooter Dogfight AI Rotation

    I'm trying to make a 2d space game involving a sort of space dogfight between the player and some ai bots. I need help with the enemy ship automatically rotating towards the player, but not being exactly pointed towards the ship 24/7. I want the enemy ship to have some "lag" in its response to the player's movement so it's more realistic. Right now I have a model which is not realistic and would probably be too hard for the player to win: update: function(){ //blah blah var tempAngle = Math.atan2(fightSprites.player.y-fightSprites.enemy[i].y, fightSprites.player.x - fightSprites.enemy[i].x); //gets angle between player and enemy fightSprites.enemy[i].body.rotation = tempAngle + (3.141/2); //too precise }
  8. [SOLVED] AI movement question

    Alright, been stuck on this for a few days and starting to think I'm overlooking a very simple solution. I have a character that I want to walk back and forth on the screen. He needs to walk to one edge, turn around, then walk to the other edge, again turn, walk, etc.; rinse and repeat. I've tried simply '+=' and '-=' on his x coord with an if statement but he wont seem to walk in the other direction. Example, writing 'steve.x += 1;' then 'steve.x -= 1;' won't work. He gets to one edge but then stops. I've also tried using tweens but he seems to become jittery as he's a spritesheet already, maybe? His physics body will stay, but the pixels themselves seem to move outOfBounds. Anyway, here's the full code for what I'm working on, any help is greatly appreciated. Also still learning Phaser so any feedback on code flow is helpful too! Thanks!
  9. Hi everybody, I have another question for the brain trust. I am working on a plane game. I am able to control my plane perfectly fine and I have replicated the plane class to create enemy planes. The question I have is what is the best way to efficiently create a simple AI system for the enemy planes? Here is what I was thinking: I attached a screen shot of a plane with some lines to demonstrate what I was thinking. There would actually be 9 lines total but I am showing on 3 lines. If I detect an "obstacle" mesh via the right rays, then I would have the plane move left and conversely for the opposite. If I detect an "player" mesh on any of the rays, then I would rotate and fly towards the plane. I have played with simple line meshes to do the same thing but I was worried it could be less efficient if I had a large collection of obstacles and players objects to loop through to detect a collision. Any thoughts would be greatly appreciated!
  10. Hi, Recently, I was working on this artificial neural network that read emotion from human drawing in real time. Here is an interactive demo link. It evolves everyday. You can also teach her, currently over 10,000 people have their drawings to teach her. I made a small library of it.
  11. Crajsh

    Crajsh is a simple game we made back in early 2011. I remember getting the sound to work, the GC not to pause, and the canvas to go fast enough was a bit of a challenge (Firefox was at version 3.6). Play it:
  12. I am currently building the AI for some baddies in a simple video game I'm making. The levels are mostly horizontal with some floating platforms here and there. Using `enemy.state` as an attribute to keep track of what the enemy is doing and by tracking the x and y distances between the player and the baddies, I am able to create a semi-working AI system. But there are still glitches. For example: if the baddie is on a hovering platform and the player is directly below that platform, the baddies doesn't know to walk off the platform to get to the player. Are there ways to create "rays", like with Unity? Essentially, a "ray" is an orb that surrounds the object and detects its relation to other things around it. This way the object can navigate levels in a human-like way. Anything along those lines, or any AI tips and techniques/tutorials would be greatly appreciated!
  13. So I'm try to get my enemy sprite to follow a motion path and depending on direction the sprite will change animation. So turning left will show the left side, moving up shows its back and moving down shows its face. I can't seem to get it to work, through hours of struggling with it. any help would be appreciated. Here is my code. I almost had it working with prototype, but the final game will be built in this format. /* * initalise Phaser framework with width:960px, height:540px */var game = new Phaser.Game(960, 540, Phaser.AUTO, 'gameContainer', { preload: preload, create: create, update: update, });/* * Preload runs before the game starts. Assets such as images and sounds such be preloaded here. * A webserver is required to load assets. * * Also in this function we set game scale so it full browser width. */function preload() { // set to scale to full browser width this.scale.scaleMode = Phaser.ScaleManager.SHOW_ALL; this.scale.parentIsWindow = true; //set the background color so can confirm the game renders in the browser this.stage.backgroundColor = '#4488cc'; = true; //preload images & sounds //game.load.image('key', 'folder/filename.png');//this.load.image('nazi', 'image/nazi.png');game.load.spritesheet('nazi', 'images/nazi.png', 128, 128, 6);this.bmd = null; this.alien = null;this.mode = 0;//Use this website to set enemy movements Export save data from the console log.this.points = {"type":0,"closed":true,"x":[120,120,260,260,200,180,120],"y":[368,108,108,308,308,368,368]};this.pi = 0;this.path = [];}/** Add game variables here*/var nazi;/* * Create runs once only when Phaser first loads * create the game scene by adding objects to the stage */function create() {bmd = this.add.bitmapData(,;bmd.addToWorld();/*For testingthis.alien = this.add.sprite(0, 0, 'alien');this.alien.anchor.set(0.5);*/this.nazi = this.add.sprite(0, 0, 'nazi');this.nazi.anchor.set(0.5);var py = this.points.y;/*Original Code//define the animationnazi.animations.add('walk');//start the animation at'walk', 3, true);*///define the animationthis.nazi.animations.add('walkDown', [2, 3]);//start the animation at'walkDown', 3, true);//define the animationthis.nazi.animations.add('walkLR', [4, 5]);//start the animation at'walkLR', 3, true);//define the animationthis.nazi.animations.add('walkUp', [0, 1]);//start the animation at'walkUp', 3, true);}function plot() {this.bmd.clear();this.path = [];/*ROTATION CODE*/var ix = 0;/**///Sets the speed of the spritevar x = 0.5 / game.width;//looping through plotting points from x and y arrayfor (var i = 0; i <= 1; i += x) {var px = this.math.linearInterpolation(this.points.x, i);var py = this.math.linearInterpolation(this.points.y, i);/* ROTATION CODE to follow direction of path*/var node = { x: px, y: py, angle: 0 };if (ix > 0){node.angle = this.math.angleBetweenPoints(this.path[ix - 1], node);}this.path.push(node);ix++;/**///this.path.push( { x: px, y: py });this.bmd.rect(px, py, 1, 1, 'rgba(255, 255, 255, 1)');}for (var p = 0; p < this.points.x.length; p++) {this.bmd.rect(this.points.x[p]-3, this.points.y[p]-3, 6, 6, 'rgba(255, 0, 0, 1)');}}/* * Update runs continuously. Its the game loop function. * Add collision detections and control events here */function update() {plot();// Reset the players velocity (movement) //this.nazi = 'nazi'; /* For Testingthis.alien.x = this.path[this.pi].x; this.alien.y = this.path[this.pi].y;//ROTATION CODE: this.alien.rotation = this.path[this.pi].angle; */this.nazi.x = this.path[this.pi].x; this.nazi.y = this.path[this.pi].y;//this.nazi.rotation = this.path[this.pi].angle;this.pi++; if (this.pi >= this.path.length) { this.pi = 0; }/*// Flipping the player image based on the velocityif(nazi.body.velocity.x > 0){ //player is moving right nazi.scale.x = -1;'walkLR'); } else if(nazi.body.velocity.x < 0){ //player is moving left nazi.scale.x = 1; //flip the image'walkLR'); } else if (nazi.body.velocity.y < 0){'walkUp'); } else if(nazi.body.velocity.y > 0){ //player is not moving'walkDown'); }*/}
  14. Enemy rotation AI degrees problem

    Hi, yesterday i was struggling with rotation of an enemy. In my game you drive a spaceship and the enemies should rotate to your location in the nearest way (left or right), so they can follow you. This seems to be simple, but i find some problems in the rotation degrees. First i have to find the angle that the enemy should have, to point to my spaceship. I find two ways to do it. The first doesn't work: angle = game.physics.arcade.angleBetween( this , player ); // returns angles between something like 3.1 and -3.1// ( this = Enemy class )I don't know why. Maybe because i am using p2 physics and not arcade? The second works: angleRadians = Math.atan2(this.position.y - player.position.y, this.position.x - player.position.x);angle = Math.atan2(this.position.y - player.position.y, this.position.x - player.position.x) * 180 / Math.PI;// returns 180 to -180So i use that instead. Here I find something strange, the 0° angle in the Enemy is on Top. But, the 0° angle returned in the var angle is on the left. ( both ways in clockwise ) Finally i try doing something tricky like this, but doesn't work properly: if( this.body.angle+180 - angle-90 <= 180 && this.body.angle+180 - angle-90 >= 0 ){ this.body.angle += .6;}else{ this.body.angle -= .6;} May if I figure out why the degrees are different, i can get it work. Thanks!
  15. Help needed for better enemy AI

    Hey everyone! I'm making a top-down game with waves, but the problem is the enemy AI. As it stands now the enemy rotates and goes towards the player, but when they all go after the player they come close to each other and it looks silly, like this: The thing is that I want the enemies to avoid eachother so they don't collide. If anybody knows how to do this, help is really appreciated! this is my code for their behavior: enemy1Group.forEachAlive(function (enemy) { enemy.body.rotation += 20, enemy.body.collideWorldBounds = true, enemy.body.velocity.x = 0, enemy.body.velocity.y = 0, chasePlayer(enemy); ; }) function chasePlayer(enemy) { if (player.alive) { game.physics.arcade.moveToObject(enemy, player, 150); } }
  16. group tween animations

    I have a group of enemies in a project i'm working on, I want them to move independent from one another, I can do this, but the animations are playing up. There is easing even though I have set it so there shouldnt be, also whatever I do the tween wont yoyo, repeat etc. Chaining is also not working, here is an example of what i'm doing: var enemyOne = this.enemies.children[0]; game.add.tween(enemyOne).to({x: 220}, 50, Phaser.Easing.Linear.None, true, 0, 0, true); What am I doing wrong, shouldnt this line make the enemy return back to its original position? Thanks
  17. Tween animations acting strange

    I'm trying to add some movement to the enemies in my game, I have a function which includes the following: var enemyMovement = game.add.tween(this.enemies.children[0]);{x: 230}, 1000, Phaser.Easing.Linear.None) .to({x: 50}, 1000, Phaser.Easing.Linear.None) start(); I have two problems: 1. I want the sprite to move at a constant speed, at the moment there is easing which I thought Phaser,Easing.Linear.None would handle. 2. The chaining will not work, the sprite will not move back and I have not idea why, I am getting no errors in my code. Thanks
  18. This board game is available online: My focus was on the computer AI. This game has five computer opponents and the champions mode is very powerful, but it's responding fast without making long calculations for the next move! Actually I wanted to develop this game for iOS only, but then I discovered the JavaScriptCore Library by Apple. I was exited, because my JavaScript code in this project works a lot faster than other Othello engines written in C. And the best of all: it can also be used for other platforms! This game is also optimized for mobile devices and I tried my best to create a polished design.
  19. AI Tree plugin for Kiwi.js

    The AI Tree Plugin for Kiwi.js allows you to create powerful, easy-to-understand behaviour trees to drive intelligent behaviours on your game entities using behaviour trees. Behaviour trees are great for quickly developing sophisticated behaviours... Curious? Read more and see examples @ Kiwi.js
  20. AI enemies do things from time to time, etc ... It is time in my game, I have to create enemies. I do not know how to deal with the issue, I would like you to tell me some options there. How to make the enemy walk to the left and to the right, jump from time to time, etc .... that sort of thing. Thanks!!
  21. [Phaser][WIP] 8Puzzle

    Hi! today my last game became "playable" You can find it here : To play use the arrow keys And the source code: Currently its using Phaser 2.0.2 It is an attempt to improve my JS and AI skills, the objective is to get the right order of the numbers, I used A* algorithm to find the answer, at the moment you can see the progression opening the console and hiting the arrow button. I will really appreciate if someone could tell me any feedback on my JS or AI skills based on the code or any feedback actually When I implement the solving animation will update this
  22. 8 Sliding puzzle

    Hi all, today y manage to make my little AI exercise to work, it's a classical path finding exercise using A* to solve, this is my first JS medium/heavy project and it can be improved A LOT mainly because I did the A star thing myself from scratch which was fun but hard. It needs some cool animations and player control improvements but if you run it and open the console you can see all the steps to solve it when I'm finished it will be on my website but for the time being here is the source code. If any one could check it out and tel me if something could get improved i will appreciate it a lot I have being studding JS and checking other people code and I think I did good practices but I'm not sure. (I'ts SLOW so if you run it it may look like it will crash but hang on and it will solve the puzzle , I think this is because my heuristic isn't the best but i will try different one soon) If someone is interested o could do a tutorial for this so let me know.