How do I create a CPU actor that attacks another actor?
Hi,
I'm trying to create an actor that every random(2,4) attack another actor. The other actor is moved by the player. I have no idea how to tell this actor to attack (go on the position) of the actor controlled by the player.
Any idea?
Second: in gamesalad, can we intercept the velocity of a collide between two actors?
Thanks and cheers
I'm trying to create an actor that every random(2,4) attack another actor. The other actor is moved by the player. I have no idea how to tell this actor to attack (go on the position) of the actor controlled by the player.
Any idea?
Second: in gamesalad, can we intercept the velocity of a collide between two actors?
Thanks and cheers
Best Answers
-
fadamion Posts: 309
Add a global attribute called "help me" then when you attack tell 2nd actor to attack.
in 2nd actors code you will need a vector to angle telling 2nd actor to go to the actor your attacking.
something like this
vectorToAngle( game.playerX - 2ndactors.Position.X , game.playerY - 2ndactors.Position.Y ) -
Fredrik Bixo Posts: 239
@patapple yeah i have also discovered that its pretty hard to make "artifact intelligence" in gamesalad
Maybe this can help you: -
JohnPapiomitis Posts: 6,256
@johnPapiomitis no, i need to create an enemy actor that is going to play with the player. The player has an actor and he need to destroy the cpu actor just going again it. The cpu actor must counterattack it. I think to create a system like this one is a little bit complicated with my capacity. I think i never see a gs game with a system like this one. I'm wrong?
Theres been other gs games with systems like that, cause ive made some before.
You need to set up states if you want differnent counteractions based on what the player does.
Quick Example:
Attribute called player state, self attribute in ai called whatever.
When the player attacks change playerState to 1
In ai when playerState=1
-change attribute to random(1,2)
When attribute =1
-do counter behaviors
When attribute = 2
- take damage
Next state
When player hits button to flee battle or whatever
-change playerState=2
In ai when playerState=2
- change self attribute to random(3,4)
When attribute = 3
- do nothing
When attribute = 4
- move to or interpolate to or whatever behavior you just to the playersX and Y to follow him.
Youll need to set up states and counterstates for everything.
Each number for that self attribute will represent a differnt counteraction based on the player state. You can give it more of a span in the random expressions to change the odds.
You can also use writeable tables which im sure would make it easier.
Answers
Change attribute selfposition X to GamePlayerX and Selfposition Y to GamePlayerY
And then make the player constrain selfpoistion to Gameplayer Y and X
Every 2,4 sec
change selftempX and selftempY to selfposition x,y
Change attribute selfposition X to GamePlayerX and Selfposition Y to GamePlayerY
when "other actor" collides with player change self position to temp x,y
And then make the player constrain selfpoistion to Gameplayer Y and X
does it work?
So you think it would be easier to code it? Dont take this the wrong way, because im not trying to sound rude or mean on purpose. But its not that its to hard in gamesalad, its that its above your skill level.
Your saying you want to make a complex ai enemy actor, then your asking how to do it. We cant just tell you how to set up the whole system. You need to do it and ask specific questions when you get stuck on something. Your not really explaining to good what your trying to do either.
And yes you can get the velocity on collide. Just make game attributes and change those to the objects motion linear x and y when it collides, then you know how fast/hard it collided.