Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Getting stuck in rules. Variables not updating.

Posts: 10Member

I have player that is supposed to move to your mouse in an exponential decay type of momentum. (distanceToMouse/2)

The lagic staff from top to bottom in player:

`````` Change Attribute: distanceToMouse to (distance to mouse using magnitude)

Rule:

If (distanceToMouse) > 50
move in direction: (vectorToAngle...) at speed of (distanceToMouse/2)
``````

It never updates the distanceToMouse variable. Does gamesalad get stuck in rules? I thought the logic staff went through itself top to bottom forever.

• Posts: 9,901Member

Show all the function as you have it written. You can't show part of it like you have. That works under the assumption you did that part right and it may well be wrong.

• Posts: 10Member

distanceToMouse: magnitude(game.Mouse.position.x-20-self.position.x, game.Mouse.position.y-20-self.position.y)

Point to mouse: vectorToAngle(self.position.x-game.Mouse.position.x-20, self.position.y-game.Mouse.position.y-20)-180

**

This is also happening to my spawner for enemies as well, it is supposed to keep repeating with the rule

`````` If enemiesSpawned < enemiesThisWave then
Spawn actor "enemy" at 0,0 relative to actor.
``````

It only spawns one enemy, then stops. Even if I set the value manually to 15+

• Posts: 9,901Member
edited November 2015

Okay so I see an issue when doing math inside an expression you need to braket that off. The above is an invalid expression and therefore will not work.

Magnitude ((game.mouse.position.x -20)-self.position.x,(game.mouse.position.y-20)-self.position.y)

Point to mouse vectortoangle (self.position.x - (gamemouse.position.x-20),self.position.y - (game.mouse.position.y-20))-180

• Posts: 10Member

@Lost_Oasis_Games said:
Okay so I see an issue when doing math inside an expression you need to braket that off. The above is an invalid expression and therefore will not work.

Magnitude ((game.mouse.position.x -20)-self.position.x,(game.mouse.position.y-20)-self.position.y)

Point to mouse vectortoangle (self.position.x - (gamemouse.position.x-20),self.position.y - (game.mouse.position.y-20))-180