Ambiera Forum

Discussions, Help and Support.

Ambiera Forum > CopperCube > Programming and Scripting
Could someone look into this, please? :)

j9907
Registered User
Quote
2018-11-17 13:32:55

Could somebody be so kind to look into extending this behavior for me? It was made by Niko. It fixes the jump animation issue and is ideal for my game, but 2 issues are holding me back:

1: There's no "Disable without active camera" option. I don't know if this can be added...

2: If you have a "when key is pressed do something" event and have it execute an animation (such as an attack), it doesn't play it and keeps playing the idle animation...


http://www.ambiera.com/coppercube/extensions/behavior_moveObjectByKeyboardWithJump.zip


If anyone can look into this, do let me know. I'll try and see if I can pay you for your help as well (I don't have PayPal - I think PP allows people to make transactions with a debit card via their service so that'd work)


tim12345
Guest
Quote
2018-11-17 14:02:28

hm...what are you saying by "Disable without active camera"? like, when you switch to a different camera? or if there are literally no active cameras anywhere?


j9907
Registered User
Quote
2018-11-17 14:15:18

I'm meaning I want the character to be uncontrollable if the camera is different from the one which is used for the player. I do in-game cut-scenes and I can't have the main character running around during them :) heh


tim12345
Guest
Quote
2018-11-17 14:22:29

ah, i see... why i'd say that is very doable!
I'll look into it a bit later if nobody else does.


tim12345
Guest
Quote
2018-11-18 08:34:09

i've now looked into the file mkay... and modified it slightly mkay...

first I added a few new properties at the top of the script:
<property name="DisableWithoutActiveCamera" type="bool" default="false" />
<property name="NameOfCamera" type="string" default="Camera1" />

now you will have to reload the behaviour because of this, (restart coppercube, remove the behaviour, and add it once again, so remember your settings). one is a check box and one is a text field where you will now have to enter the name of the camera that is following the player.

then I added this code near the start of the script:
var cam = ccbGetActiveCamera();
var name= ccbGetSceneNodeProperty(cam, 'Name');


this will get the active camera's name. then i will input this code:
if(this.DisableWithoutActiveCamera ==true){
if(this.NameOfCamera!=name){
this.freezemode=1;
ccbSetSceneNodeProperty(node, 'Animation', this.StandAnimation);
ccbSetSceneNodeProperty(node, 'Looping', true);
this.PressedJump = false;
this.loopJumpAnimation = false;
}
}

which asks if the "disable without active camera" option is checked and if the camera you typed into the text field is not active. if so it will set a variable called "this.freezemode" to 0, and it will also disable some jumping things.

then i wrote:
if(this.DisableWithoutActiveCamera ==false){
this.freezemode=0;
}

which says if you have the "disable without active camera" box unchecked, simply set "freeze mode" to zero.
And also:
if(this.DisableWithoutActiveCamera ==true){
if(this.NameOfCamera==name){
this.freezemode=0;
}
}

that says if the "disable without active camera" is checked, and the current active camera is the camera attached to the player, also set "freeze mode" to 0.

now we will simply add one more line...
if(this.freezemode==0){

and we will put this before the entire rest of the controlling code, meaning, only run the code if "freeze mode" is set at zero.

here is the final code --> http://www.timiscool.net/behavio...
maybe the file is now closer to what you were asking. and hopefully my modification wont make your computer blow up.


tim12345
Guest
Quote
2018-11-18 08:42:54

edit: i said "if so it will set a variable called "this.freezemode" to 0, and it will also disable some jumping things." but meant to say " "this.freezemode" to 1." a slight typo.


j9907
Registered User
Quote
2018-11-18 08:53:29

That works perfectly (the "disable without active camera" feature), though I noticed the animation issue is still occurring (also the jump is now affected). If you could look into that, then it'd be 100% usable for my project :) Thanks a ton... I didn't think it would be possible to implement that via JavaScript...


tim12345
Guest
Quote
2018-11-18 08:58:10

oh! i forgot about the animation issue... right.... i think the problem is the script and the "when key is pressed do something" event conflict with each other, and would be best to write the key event into the script itself.

what do you mean exactly by "also the jump is now affected"?


j9907
Registered User
Quote
2018-11-18 09:02:48

Basically when you press jump, the jump animation doesn't play now sadly (whereas it played just fine before)


tim12345
Guest
Quote
2018-11-18 09:08:12

ah damn, i broke it! it should just need a slight modification... i'll take a look...


tim12345
Guest
Quote
2018-11-18 09:17:59

hm... not sure whats going on there. my jump animation is still functioning...


j9907
Registered User
Quote
2018-11-18 10:03:30

Yeah I'm not sure... It's not working... I might just give up on CC. It's showing it's limits as I mess with it more and more


tim12345
Guest
Quote
2018-11-18 10:16:58

ah, i'm sorry to hear that. like i said it works for my default character so maybe there is some miscommunication going on between us.


j9907
Registered User
Quote
2018-11-18 12:10:57

If the existing character behavior's jump animation worked properly, then I could use that... Meaning, the built-in one in CC.


tim12345
Guest
Quote
2018-11-18 12:25:11

ok but you say the jump worked fine before i modded it... can you send an example file so i can actually see what the difference is in the jumping animation before and after i add the modded behaviour?


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