lazerquest's Recent Forum Activity

  • hi so im currently making a game that i will export soon as a desktop/mobile app. only problem i keep running into is that when someone opens the game for the first time on their device, some assets don't load in, most especially the eye boss.

    construct.net/en/free-online-games/idk-game-test-61752/b21a68aa-d379-49a2-aa33-2e08dd08e366

    here is a link to my game for anyone to try for themselves. any way to fix this?

  • How do you actually move the enemies though, I'm assuming pathfinding behavior? That's just the code for finding the targets, which looks fine.

    I think what might be the issue in your case is a setting in the pathfinding behavior, specifically the "rotate object" setting, which you can probably disable in your case. Or it's the acceleration being too slow, and you could increase it.

    I've set it like this so it will check every tick if the enemy has a path to move through I'll try doing what you've said and the rotation is already disabled and about the speed, I'll try manipulating it thanks for the idea!

  • Can I see the code?

    here

    let allEnemies = [];
    let targets = [];
    
    export function findTarget(AllEnemies,runtime){
    	
    	var tempTargets = runtime.objects.Plant.getAllInstances();
    	tempTargets.push(runtime.objects.Nyardo.getFirstInstance());
    	tempTargets.push(runtime.objects.Tree.getFirstInstance());
    	
    	var player = runtime.objects.Nyardo.getFirstInstance();
    	
    	allEnemies = AllEnemies;
    	
    	allEnemies.forEach((enemyInstance) => {
    	
    	var dists = [];
    		
    		if(enemyInstance.x != null){
    		
    		tempTargets.forEach((targets) => {
    	
    		const distance = calculateDistance(targets.x,targets.y,enemyInstance.x,enemyInstance.y);
    	
    		dists.push({TargetUID: targets.uid , TargetDistance: distance , targetX: targets.x , targetY: 				targets.y});
    	
    		});
    		
    		}
    	
    	
    	
    	const thisEnemyTargetDistance = Math.min(...dists.map(obj => obj.TargetDistance));
    	const foundTarget = dists.find(obj => obj.TargetDistance == thisEnemyTargetDistance);
    	
    	enemyInstance.instVars.targetX = foundTarget.targetX;
    	enemyInstance.instVars.targetY = foundTarget.targetY;
    	
    	
    	console.log(foundTarget);
    	
    	
    
    	
    	});
    
    	
    	targets = tempTargets;
    	allEnemies = AllEnemies;
    
    
    
    }
  • So I created a way to make my object find path towards the closest target then move towards that path, the problem is the target position is always changing so it have to change it paths then move to it again, this cause the object to pause for a moment making the movement a bit annoying here is an example video

    :LINK:https://youtu.be/QNntToljCpg

  • nvm I solved it

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • So i know that in order to access the instance variable is I need to do it like this

    [code lang="javascript"]	enemyInstance.instVars.variableName;
    
    

    but, How do I change the value of the given variable?

  • It's quite simple, your import statement:

    > 	import * as Utils from "./utilities.js";
    

    Notice that you import the functions "as Utils".

    > 	addEnemyUID(AllEnemies, EnemyUID); // This is not defined
    	Utils.addEnemyUID(AllEnemies, EnemyUID); // But this is
    

    In other words, all the functions of Utils will be available under Utils.

    Ohhhhhh THANKYOU!!!

  • so I'm literally crying right now as the function I created is not working saying that it is not defined I thought that it is because the scope of the function can't reach the scriptsInEvents.js so I use import following this construct.net/en/tutorials/upgrading-projects-classic-2652

    and it's still now working idk what to do T_T

    the code in event sheet is like this

    var AllEnemies = runtime.objects.EnemyDetector.getAllInstances();

    var EnemyUID = [];

    addEnemyUID(AllEnemies, EnemyUID);

    console.log(EnemyUID);

    var temp = AllEnemies[AllEnemies.length-1];

    console.log(temp.uid);

    and the function on the utilities.js which is addEnemyUID()

    export function addEnemyUID(AllEnemies, EnemyUID){

    var instance = AllEnemies[AllEnemies.length-1];

    EnemyUID.push({id: instance.uid});

    }

    importsForEvents.js

    import * as Utils from "./utilities.js";

    I'm new to construct and javascript so I might have some error in the way I code or iDK please educate me T_T

    Tagged:

  • Basically this?

    function hex2dec(hex)
    — var num=0
    — repeat len(hex) times
    — — num = num*16+max(0, find(“0123456789abcdef”, mid(hex,loopindex,1))
    — return num

    Btw your example is odd to me. W isn’t a hex digit.

    Hello R0J0hound I found this comment of yours 9years ago

    Another interesting idea would be to use

    http://en.wikipedia.org/wiki/Dijkstra%27s_algorithm

    The idea is to use an array to store the direction to move for every spot to get to the target with the shortest distance. It's just as easy to have more than one target so it's good for many objects that need to find a path to the same set of targets.

    So after the array is calculated objects can move to the closest target by just referencing the direction of the square it's currently on.

    https://dl.dropboxusercontent.com/u/542 ... eSpot.capx

    In the example I made the objects accelerate toward the direction instead of just setting the direction. The result was nice rounded turning.

    It caused a stall if I calculated the array all at once, so I adjusted it to only calculate a bit at a time.

    the dropbox link is broken again :( may I ask for a fixed one if possible? thankyouuu

  • MyXpandaZ calminthenight

    The simulation is rather basic so I can lead to instability.

    I'm not sure how you're moving the sprites toward the target, but it's better to set the velocity than setting the position, and better than that is to gradually change the velocity. In general that allows everything to be more stable. Another thing you can do is limit the max speed the objects can move. Another solution is making the push out less rigid. As is it pushes each pair out of each other completely in one go, but changing it so it only moves apart 25% of the way or lower will smooth things out more. Look for the js line that sets dist. There should be a /2 at the end. Change that to /10 to make the pushout softer.

    I probably need to revisit this to clean it up.

    Here's were I tweaked the example from last week but it deviated a fair bit as I was messing around with various ideas.

    https://www.dropbox.com/scl/fi/adgm5izhyk7indhjbqlz4/spatialGridJS2.c3p?rlkey=oafjw813djgai8x9pddbaq6ke&dl=1

    the file is not accessible, may I get a new link?

lazerquest's avatar

lazerquest

Member since 28 Jan, 2021

Twitter
lazerquest has 1 followers

Trophy Case

  • 3-Year Club
  • Regular Visitor Visited Construct.net 7 days in a row
  • RTFM Read the fabulous manual
  • Email Verified

Progress

6/44
How to earn trophies