A battling game with a knight attached to the camera

Hello,

One of my student is trying to create a battling game. His “player” is a knight with a shield and a sword and he will battle various characters available in the library like the pirate mates and the pirate captains. We are encountering multiple problems.

(Question 1) When I attach the knight to the camera (under the camera) and try to “play,” the knight falls whenever I use the mouse to change my view. I have played around with the physics of the knight using various mass and friction but have not been able to figure it out. I know that it works fine if the physics mode is turned off but in order to do the battling, I think the physics mode has to be turned on, doesn’t it? Has anyone done a battling scene/game with swords and shields in CoSpaces?

(Question 2) My student also wants to change the functions of up, down, left and right arrow. He wants the same functions to be kept so that both the camera and the knight are moved when the up, down, left and right arrows are pressed. But in addition to that, he’d like the animation of his “player” - the knight - to be changed to walking while the key is being pressed. Does anyone know how to do this?

Any ideas will be appreciated. Thank you!

1 Like

Hi @makamaka,

  1. I have tried to use knight with physics and attached camera and it works. Here is my example:
    CoSpaces Edu :: Knight with camera
    You can remix the CoSpace so you can see its content. If it doesn’t work in your CoSpace, please remix it and send the link so we can take a look at it.
  2. There is a “When {} key is {pressed}” CoBlock in Events category. In the example above, I used it to reassign up and down keys to play different animations.

However, I would not recommend attaching camera to the knight, because when knight plays its animation it may be dizzy for a player. You can control camera and knight separately but with the same values so the camera would not jump.

Feel free to ask any questions, if you have them. Hope that helps

Thank you so much for making the example for me.

Actually, what the student wants to do is have the knight and the camera move forward just like it is in the default setting when the up arrow is pressed AND at the same time change the animation of the knight just when the “up arrow” is pressed. I tried using the “run in parallel” coding block but could not get it to work in the desired way. I think I have found a workaround. I am going to have to recommend to the student to keep the up arrow function as the default setting has but use another key to have the knight’s animation change to walking using the key down/up coding blocks.

I can see that many problems exist with an animated knight being attached to the camera. I am also trying to apply physics to the knight so that the battling characters can’t just walk through each other and new problems emerge when physics is applied.

I am not able to see the remix button when I see your example. Could you check if you have allowed remix?

Here is my example - https://cospac.es/155Z

Thank you again very much!