Ambiera Forum

Discussions, Help and Support.

Ambiera Forum > CopperCube > Help with CopperCube
How To Walk & Attack Simultaneously?

hadoken
Guest
Quote
2020-12-28 21:16:01

My 3rd person player has got the following behaviors assigned:

-> "Object or Person controlled by keyboard" &

-> "When a key is pressed do something" (left Mouse-Key for switching to Attack animation)

Problem:
While the player is walking forward by pressing "W" there's no attack animation triggered when additionally pressing left Mouse-Key.

I want the Player to be able to attack while still walking forward.

How can this be solved correctly?

Thanks for any hints and solutions.


veganpete
Registered User
Quote
2021-01-08 23:42:42

Presumably what's happening is while "w" is pressed, the animation is "walk". When "left click" is then pressed, it triggers the attack animation.... but because"w" is still being pressed when "left click" is released, it's still playing the walk animation instead of the attack animation.

To fix it, I think you just need to add a couple of simple variables to clarify the various states of walking/attacking...

When "left click" is pressed, set variable "attack" =1.
When "left click" is released, set variable "attack" =0.

When "w" is pressed:
If [variable] "attack"<>1, switch to walk animation.
Else:
If [variable] "attack"=1, switch to attack animation.

Setting the variable "attack" to 1 or 0 this will prevent the wrong animation playing when "w" is pressed.


hadoken
Guest
Quote
2021-01-13 12:39:43

Thank you veganpete for your support!

I was wondering when I assemble just action and behaviors together without the use of variables, A,S and D keys do always work great when keeping pressed and triggering a new animation with additional left mouse button, only W key does not work here out of the box, strange & a pity :-(

Nevertheless, a solution with variables for clarifying keys and animation states does the job well now, I think.

As another solution, I found out, that although animations are not triggered well, scaling is triggered just fine. So I came up with exchanging a clone of the character with permanently assigned attack animation by default. Then original and clone could easily be made visible with opposite scaling of 0 and/or 1 of the two, depending on which animation being triggered.


veganpete
Registered User
Quote
2021-01-21 09:24:52

You're welcome! Yes, the "scale object" and "make invisible/visible" trick works for me too to switch between different models. I think the default actions/behaviours are really just intended as general/basic examples to get your game developed fairly quickly.

As you get more confident and find extra things you want/need in your game, you can get under the hood of coppercube and write your own simple/complex java actions/behaviours to completely/partly replace the defaults as and when needed.

You can also use plugins (which other people have written) to add extra features/functionality or "inject" your own quick scripts (on the fly) with the "Special>Execute Java Script" action.

That way, you can achieve pretty much anything you want and only code when/if you need/want to.

A quick reference is provided (with basic examples to get you started) if you click "Help" in Coppercube program and then click "open document in browser", then navigate to the "Java Scripting Reference".

Having said that, all of my game so far is without any coding, just the default actions and extra plugins (which I downloaded from the Ambiera site) - so I've not delved into the endless possibilities of scripting/coding with coppercube yet.

If you're anything like me, I'm enjoying finding work arounds to get the same job done without having to rely on any coding. Coppercube seems solid in that respect and the more you play around with it, the better you get and the less restrictive it becomes if you can get your head around Java Scripting as well, I'm pretty sure you'll be able to do anything you with coppercube with very few problems.


Create reply:


Posted by: (you are not logged in)


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