ambiera logo

Ambiera Forum

Discussions, Help and Support.

folder icon Ambiera Forum > CopperCube > Feature requests and bug reports
forum topic indicator Suggestion for Object or Person Controlled by Keyboard
person icon
morbott
Registered User
Quote
2025-11-09 01:19:54

Hi... incase you see this Nico (or anyone who has the power to do this)... one suggestion for the "Object or Person controlled by keyboard" Behavior. The suggestion is that the Move Speed be broken into Forward Speed, and Backward Speed. This will allow the user to control the speed of both directions. In my case.. I would like to have my object NOT move backward. If there was a forward and backward value, I could simply set backward to 0.
Anyway... something to consider (I hope).
Thank you,
M

person icon
Monks
Guest
Quote
2025-11-09 07:05:23

Hi morbott, you are right, this is necessary, but i think you can plan a workaround by executing a javascript when the down arrow key or S is pressed, to decrease movement speed=0,
this might not affect the animation but there is a way to gain control of the player's animation, with the most helpful being,child the animated node to an invisible node and put the controlled object by keyboard behaviour to the invisible node, hence you have the ability to set the animations manually
All this is kinda a lot of work. it would have been simpler if what you suggested was actually implemented though

person icon
morbott
Registered User
Quote
2025-11-09 17:19:47

Can you change an attribute of a behavior with Java script?
If so, are there any examples I can look at? This might be going beyond my skill level. :(
But I'll try if I can see an example.

person icon
wing
Guest
Quote
2025-11-09 18:39:00

Simple example of code to set the movement speed when moving backward:

/*
<behavior jsname="behavior_backward" description="backward">
<property name="forward_speed" type="float" default="0.2" />
<property name="backward_speed" type="float" default="0.1" />
</behavior>
*/
behavior_backward = function() {
this.name_ = null;
this.move_ = false;
this.speed_ = 0.0;
};
behavior_backward.prototype.onAnimate = function(node, timeMs) {
if (this.name_ == null) {
this.name_ = "" + ccbGetSceneNodeProperty(node, "Name") + ".movementspeed";
return false;
}
this.speed_ = this.forward_speed;
if (this.move_) this.speed_ = this.backward_speed;
ccbSetCopperCubeVariable(this.name_, this.speed_);
};
behavior_backward.prototype.onKeyEvent = function(keyCode, pressed) {
if (keyCode == 83 || keyCode == 40) this.move_ = pressed;
};


person icon
okeoke
Registered User
Quote
2025-11-09 22:39:23

@wing

With that code you can press both "s" and "arrowdown" and then after releasing one of two but holding the other move with forward_speed backwards. I believe, you have to use two flags anyway.

person icon
wing
Guest
Quote
2025-11-09 23:02:11

You’re totally right, I didn’t notice that. I somehow missed the fact that two buttons control the behavior. I didn’t even test the arrow keys - just instinctively tried everything with WASDemoji icon_grin

person icon
okeoke
Registered User
Quote
2025-11-10 09:58:51

np:) I only noticed because I made the same exact mistake with sprint behavior


Create reply:










 

  

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


icon_holyicon_cryicon_devilicon_lookicon_grinicon_kissicon_monkeyicon_hmpf
icon_sadicon_happyicon_smileicon_uhicon_blink   






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