Ambiera Forum

Discussions, Help and Support.

Ambiera Forum > CopperCube > Programming and Scripting
Help with Cloning Logic

floydness
Registered User
Quote
2021-03-22 14:42:43

I've attached a ccb with my logic for a spawner.
It kind of works up until all the spawns are dead at which point it does not continue to spawn. I can't see why not.
Anyone care to take a look?

https://drive.google.com/file/d/...


just_in_case
Moderator
Quote
2021-03-22 15:26:25

Will have a look at it tomorrow.. right now am not on my pc and its night here already.


floydness
Registered User
Quote
2021-03-22 16:17:19

Ok. I do appreciate all the help I get. :)
What I'm trying to do may not really work and that's why I'm getting opinions.


just_in_case
Moderator
Quote
2021-03-23 08:29:14

I've checked your file and found that you are using the physics engine which is causing the issue. Turn off the physics engine and use collision and everything seems to work fine.
So in order to make it work with the physics engine, you need to change their position as animated.
in your cloning action where you are changing the position of the wolf to a random place in an area just checkmark the move animated option and then it will start working fine.

hope it helps


floydness
Registered User
Quote
2021-03-23 12:05:11

I wouldn't have thought of that,. Thank you.


floydness
Registered User
Quote
2021-03-23 12:34:00

Problem now is for some reason I get two wolves for what should only be one instance. One is the correct version and attached to it is another version with it's head at a 90 degree angle sticking into the terrain. Who knows? The idea is to be able to have continuous spawning. The other route would be to just load so many instances without trying to make them respawn and when they're gone they're gone but that defeats the logic of what this game is supposed to be. It's challenging.


marcw
Registered User
Quote
2021-03-24 14:02:44

Hello everybody,

Floydness, yesterday I downloaded your "wolf hunting" wip project and trying to find a way to control the cloning's process became my obsession.

In its current stage of development, your game remembers me of "The Matrix Reloaded" in that scene where "Neo" is fighting against an increasing number of "Smith". A terrific feeling for the player !

:-)


floydness
Registered User
Quote
2021-03-24 19:41:31

Yeah, it's awesome when they're spawning all over the place.
I could control it by setting a random number to oonly spawn when selected but the biggest problem is the cloning won't work if the original model is in the dead state. I tried to hide the original so you couldn't see it spawning but oddly it only works in certain positions on the map...If you can come up with a solution to make it spawn seamlessly at random positions it would be awesome. Glad to hear you're working on it. I wound up making a demo where instead of cloning I just import several examples of the same model and rebirth them individually. It takes away from the experience since you can see them come back to life but it's best I can come up with at the moment Here's the exe

https://drive.google.com/file/d/...


marcw
Registered User
Quote
2021-03-24 20:34:06

Floydness, great modesty from you.
In my opinion, you already found a good solution for those cloned wolves.

Congratulations !

Your game is very nice with those beautiful furnished country houses and its animated people and farm animals.
When the blonde lady spoke to me, I noticed that you created 3D sound.

About finding a better solution than yours, I'm afraid that it could be an impossible mission for me.

I feel like a monkey typing on a keyboard. I could perchance discover something new about the cloning process in CopperCube. But it wouldn't be the fruit of a methodic process.

What's behind the curtain ? (I am referring to a Just_In_Case's comment).

:-)


marcw
Registered User
Quote
2021-03-24 21:30:04

Floydness, I come back with this suggestion :

I found the two lines of codes posted by Sam (Smn Mhmdy Studio) in this thread https://www.ambiera.com/forum.ph... (Resurrecting the dead).

Then I inserted them in this very small script :



wolf_health = ccbGetCopperCubeVariable("[hashtag]wolf.health");

if (wolf_health ==0)
{
wolf = ccbGetSceneNodeFromName("wolf");

var wolf_position = ccbGetSceneNodeProperty(wolf, "Position");

ccbAICommand(wolf, "cancel");

ccbSetCopperCubeVariable("[hashtag]wolf.health", 100);

wolf_position.x +=50; // or a random value
wolf_position.z +=50; // idem

ccbSetSceneNodeProperty(wolf, "Position", wolf_position.x, wolf_position.y, wolf_position.z);

}



I placed that script in a behaviour "Every few seconds do something" (IntervalMS = 1000) applied on the Root Scene Node.

After that I deleted all your scripts relative to the wolf (in ActionOnDie, in GrayTree2, perhaps some other ones, I don't remember).

My conclusion : It seems that the cloning process is not appropriate for your specific project. I suppose that the cloning process don't include the behaviours of the original node. But perhaps am I wrong.



(Edit : If you are reading this comment just now, please note that I rectified a typo in the script <- I struggled with the hashtag).


floydness
Registered User
Quote
2021-03-24 22:29:13

Thanks for sharing your impression of my demo.
This all gets a bit confusing to me since I have to try to translate JS in my mind though it's fairly easy to follow. Seems to me your script would have to be repeated for every instance of the wolf.
As it stands when they are cloned they do get a separate identifier but each of those identifiers is identical in behavior to the original and I have no idea if there is a way to select an individual cloned instance and manipulate it without affecting any other. In other words it would be better to clone the animated mesh but not it's behavior then assign unique behavior to each clone.(way over my head how to do that in code)
When I first got the idea and came up with the routine it hadn't occurred to me that each clone would also be a spawner so imagine my reaction the 1st time I ran it. LOL. Anyways, it would be a nice feature to have a script that could spawn either randomly or in designated areas unique entities. Make it easy to create deathmatch games which is primarily what I'm interested in creating.


floydness
Registered User
Quote
2021-03-24 23:09:11

This one almost works but no collision

https://drive.google.com/file/d/...


floydness
Registered User
Quote
2021-03-24 23:24:04

Useable
https://drive.google.com/file/d/...


floydness
Registered User
Quote
2021-03-24 23:36:43

The last one is useable but doesn't always work. If it glitches when it begins it will fail. (Caused by clone colliding with spawner) but if spawner manages to get out of the way of the clone then it works great but there still needs to be a way to prevent the possible glitch.


marcw
Registered User
Quote
2021-03-25 00:44:33

Floydness, I come back in this thread two hours later and I just downloaded your two new CCB projects (no collision.ccb and use spawner.ccb).

Now I wonder if I correctly understood your intention about the scenario in your game.

Indeed, I thought that the purpose of the game was to eliminate the currently unique wolf in the scene.
And after having eliminated it, then a new one would appear elsewhere in the hunter's area.
Then in that context, the small script (inspired by Smn Mhmdy studio's two lines of code) that I suggested could work.

But if your intention is to populate the scene with a crowd of new wolves, then it is obvious that I am completely off the mark. Then the cat got my tongue.

Please note that I am a newbie in Java Script and in CopperCube. The easiness of that game engine is hiding some dark sides.

:-)


Create reply:


Posted by: (you are not logged in)


Enter the missing letter in: "?nternational" (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