One of my students wants to make a battle scene in the Colosseum. Basically the player would enter the forum and battle gladiators, large animals etc. We have been experimenting to try to figure it out but thus far we’ve been unsuccessful. We’ve tried attaching the camera to the eyes of a battling knight and Roman soldier but when you press play, the view is disorienting. We’ve also tried to parent a lone sword with the camera but unfortunately the camera doesn’t move. Is there an way to do this?
Hi @TechWarriors,
I have an example with animation and switching weapons here:
Feel free to remix it and, if need be, simplify it. The concept is that you parent the sword to the camera instead, that way the camera still moves as it would normally and the sword automatically follows it.
Luc, I don’t know what I would do without you. Your Vampire Hunter game was the inspiration for my student. I did look through the code of the game but it is pretty complicated and was unable to isolate its location. I’ll take a look through the test. Thank you Luc.
Hi Luc,
I am experimenting with the code. I noticed you have code to swing the weapon when pressing a specific key. How do you get the edge of the weapon to swing as opposed to the full weapon to spin?
Bets way is to add a dummy object like an invisible cube to the base of the handle as an axis to rotate, then simply rotate the sword.
I’ve attached here an example with some comments to explain some things, including how to make the animation feel more lifelike by rotating the sword towards the player first, imagine hitting a hamer we don’t rotate the hammer to the nail immediately but instead rotate it towards our selves to create leeway.
Also yellow event blocks do not need to be put in a forever loop or run parralel loop; They become active once the code reads it and will stay that way until you tell the computer otherwise, essentially they have a “forever loop” around them by default.