Ambiera Forum

Discussions, Help and Support.

Ambiera Forum > CopperCube > Help with CopperCube
Repeat proximity actions?

ygm7
Registered User
Quote
2017-11-15 05:10:11

Okay, so In my game I created a simple turret by using an object and having it shoot the player when the player gets close to it. But it only shoots once. Is there a way for it to keep shooting as long as the player stays in the radius?

Also, if anyone knows a way to have a turret turn to follow the player then shoot it would be great! :)
(For some reason the regular AI behavior isn't working, so I'm using the above to make it shoot the player.

Thanks!


phodis70
Registered User
Quote
2017-11-15 07:42:22

I found this yesterday and it works ok....

https://www.youtube.com/watch?v=ZCBJSooP1mA

BUT .. Please if you can figure out how to get the firing enemy bullet to start from the gun position, not just the middle height of the model I'd love to know,

I'm new here but figured out if you make the bullet scale 1,1,4 it makes it look like a laser.

Aloso a possible time saver... I don't know why but if you select a simple unanimated cube for example as the enemy it wont shoot...where as a mesh animated man for example works great. I wish there was an answer to that as well...anyways its a start for you.

best of luck... if you figure out the height position of the bullet please let me know.


phodis70
Registered User
Quote
2017-11-15 07:43:07




ygm7
Registered User
Quote
2017-11-15 14:31:50

Thanks! I'm still looking to have repeated actions when in a proximity though.

When using the shoot action, you can chose from which scene node it shoots from, so just select the gun.

If you're not using a gun and just want it to shoot from a position in the model, set the ShootPositionDisplacement. It's a pain to figure out the exact position you want to shoot from, but it works!

Thanks! :)


wild-master
Registered User
Quote
2017-11-15 19:29:49

I created this example for you:
https://drive.google.com/file/d/...

When the playable character enters the radius, a variable will be activated.

While that variable is set to 1, the enemy will continuously shoot.

When the character leaves the radius, the variable will be set to 0, so the enemy will stop shooting.

To make the enemy turn toward the character, I used the "moveto" feature of the JavaScript function called "ccbAICommand()", and inside of the Behavior called "Game Actor with Health" that's attached to the enemy, I set its speed to zero, so the "ccbAICommand()" function will make the enemy rotate without moving closer to the main character.

Also, inside of the Behavior called "Game Actor with Health" that's attached to the enemy, I activated the checkbox that says "Can Fly". This will allow the enemy to rotate in all directions. If you want your enemy to ONLY be capable of rotating horizontally, you should deactivate that checkbox.


ygm7
Registered User
Quote
2017-11-15 23:54:09

Ah! I see now! Thank you so much!

But it does beg the question: in a game where there are multiple enemies on screen at once (each one only shooting when the player is in their set range) how would I go about setting them up?

Each with a different variable? What about the javascript?

If I name every instance of my enemy "Enemy" and just use the same bit of code over and over in each one, will every single one turn towards the player at all times?

I really appreciate your help, Thanks so much!


wild-master
Registered User
Quote
2017-11-16 00:30:55

You should give a different name to each enemy, like Enemy1, Enemy2, Enemy3.

You must create a separate variable for each enemy, like "IsPlayerInProximityToEnemy1" for Enemy1, and "IsPlayerInProximityToEnemy2" for Enemy2.

If they all have the same name, the engine will be confused and your game won't do what you expect.

This example has multiple enemies:
https://drive.google.com/file/d/...


phodis70
Registered User
Quote
2017-11-16 02:09:43

"If you're not using a gun and just want it to shoot from a position in the model, set the ShootPositionDisplacement"

...Sorry ygm7... just to confirm .. the above command is a Javascript command yes?.. I'm just checking as I can't code in Java yet and have been looking for a dropdown tab everywhere to try this our.

BTW, great example wild-master, god I must learn how to code in JS!!!


ygm7
Registered User
Quote
2017-11-16 04:55:53

No, it's a parameter in the shoot action that you can plug in numbers. I think you have to chose for it to shoot from a specific scene node though. Could be wrong. Some of what wild-master said is using JavaScript, but the displacement is build in. :)


Create reply:


Posted by: (you are not logged in)


Enter the missing letter in: "In?ernational" (you are not logged in)


Text:

 

  

Possible Codes


Feature Code
Link [url] www.example.com [/url]
Bold [b]bold text[/b]
Image [img]http://www.example.com/image.jpg[/img]
Quote [quote]quoted text[/quote]
Code [code]source code[/code]

Emoticons


   






Copyright© Ambiera e.U. all rights reserved.
Privacy Policy | Terms and Conditions | Imprint | Contact