Ambiera Forum

Discussions, Help and Support.

Ambiera Forum > CopperCube > Help with CopperCube
Using First Person Camera to make Third Person Games

ishmaru
Registered User
Quote
2018-08-05 06:03:36

As Requested this is how to use a FPS Camera to make a convincing Third person shooter. Contains an example CCB file and a Animation controller Behavior for the Character.

🔎︎


🔎︎


Download it here:
https://drive.google.com/file/d/...


srfstudio
Registered User
Quote
2018-08-08 21:49:59

This is great, I really liked how you managed the TP mechanics with FP camera. Thanx for good example & project file.


srfstudio
Registered User
Quote
2018-10-29 14:42:37

I'm making a test level based on your example but I'm running into some strange things :( I was wondering if you, or other user that has some time, can take a look at it to see what I'm doing wrong.

The things that are happening are:

1. I'm getting CC Debug Console messages: Properties Animation & Looping does not exist.
🔎︎

2. WebGL build: If I don't kill enemies in the level they just disappear after minute or two.
3. All builds: when I kill first enemy (first that is created in the editor, not his clones) he comes back to life.

Here is a link to my ccb file:
https://www.newgrounds.com/dump/...

Cheers!


tim12345
Guest
Quote
2018-10-30 17:14:59

hm... looks like somewhere in there is a script causing the debug message. the script probably isn't catching those 2 properties on the first millisecond but then finds them after the script is complete because it only prints the message once. so it should be fine. maybe...


tim12345
Guest
Quote
2018-10-30 18:20:22

actually, upon further examination... there is a behavior attached to the sci_fi_gun1 that sets animations, but the sci_fi_gun1 does not appear to even have any animations...


tim12345
Guest
Quote
2018-10-30 19:11:09

for the respawing one... the minotaurs both have this code in them activated every 2000ms:

var Player = ccbGetSceneNodeFromName("Camera1");

var Enemy = ccbGetSceneNodeFromName("minotaur");
var PositionOfPlayer = ccbGetSceneNodeProperty(Player, "Position");
ccbAICommand(Enemy, "moveto", PositionOfPlayer);


which only affects one of the minotaurs...

should probably be something like:

var Player = ccbGetSceneNodeFromName("Camera1");

var Enemy = ccbGetCurrentNode();
var PositionOfPlayer = ccbGetSceneNodeProperty(Player, "Position");
ccbAICommand(Enemy, "moveto", PositionOfPlayer);


now both will respawn... which is how it's supposed to work....

this code runs even if the minotaurs are defeated... and that would explain the "respawning" i think...


srfstudio
Registered User
Quote
2018-10-30 19:29:59

@tim12345 thank you for checking the ccb & helping.

Yes, I just realized that the name of the behavior is 'FPS Node Animation Helper' :D I always just took it as a behavior that includes animations but it's not animation-based behavior :)

Once I created separate LMB behavior & removed the Helper, the message didn't appear again.

///////// EDIT

I tried this but it didn't work. The Minotaur didn't respawn but it also didn't move towrads the player :(


var enemy = ccbGetCurrentNode();
var anima = ccbGetSceneNodeProperty(enemy , "Animation");
var Player = ccbGetSceneNodeFromName("Camera1");
var PositionOfPlayer = ccbGetSceneNodeProperty(Player, "Position");
if (anima === "walk")
{
ccbAICommand(enemy, "moveto", PositionOfPlayer);
}


///////// EDIT EDIT

I made CC print the Animation and it was 'run' for some reason. I specified 'walk' everywhere but it turned out to be 'run' nevertheless :)

So this code worked:

var enemy = ccbGetCurrentNode();
var anima = ccbGetSceneNodeProperty(enemy , "Animation");
var Player = ccbGetSceneNodeFromName("Camera1");
var PositionOfPlayer = ccbGetSceneNodeProperty(Player, "Position");

if (anima === "run")
{
ccbAICommand(enemy, "moveto", PositionOfPlayer);
print("The animation is " + anima);
}


...but I still have a disappearing of Minotaur in WebGL problem :(


tim12345
Guest
Quote
2018-10-30 20:10:40

nice, i would have suggested something like...

var Enemy = ccbGetCurrentNode();

var Health = ccbGetSceneNodeProperty(Enemy, "Name");
var healthname = ""+Health+".health";
var healthvalue = ccbGetCopperCubeVariable(healthname);

if(healthvalue>0){

var Player = ccbGetSceneNodeFromName("Camera1");

var PositionOfPlayer = ccbGetSceneNodeProperty(Player, "Position");

ccbAICommand(Enemy, "moveto", PositionOfPlayer);

var Player = ccbGetSceneNodeFromName("Camera1");
}



that will check their health and only move if they are alive.

also: this forum has hidden the HASHTAG between the first quotation marks after "var healthname =". which is an important part of the code.

but anyways, good work!


tim12345
Guest
Quote
2018-10-30 20:12:42

whoops... added the extra line on accident
var Player = ccbGetSceneNodeFromName("Camera1");



tim12345
Guest
Quote
2018-10-30 20:27:39

hm... i did not experience the WebGl disappearing of the Minotaur. i left it running for 5 minutes and they were still there...


srfstudio
Registered User
Quote
2018-10-30 20:29:25

Wow this is great! I didn't know I can have node's health reference without a variable, cheers!

Your code worked out, Minotaur was facing the player & he didn't get up once dead :)

I placed a Hashtag after var healthname = " and before "+Health+".health"; but I don't get it. I realize that it builds Minotaur.Health but why is hashtag necessary?

Did you kill him? He doesn't disappear if dead, only while he's active & only in WebGL :(


tim12345
Guest
Quote
2018-10-30 20:39:30

that's because it's a special variable built into the coppercube system...

no he was alive... very strange that he disappears for you but not for me... how many minutes does it take?


srfstudio
Registered User
Quote
2018-10-30 20:47:52

Sometimes it takes a minute or two & sometimes it's even less than a minute :(

Btw I was experimenting with only one Minotaur, now that I cloned another I noticed that they have kind of a friendly-fire thing happening :D The one died without me firing a single shot, the other one killed him by accident :) Should I change tags for each Game Actor or maybe have different bullet for enemies & player?


tim12345
Guest
Quote
2018-10-30 21:00:20

hm... if you don't want friendly fire, i would set the minotaur's 'shoot' damage to 0, an then put an 'on proximity behaviour' on the bullet, which when it hits the camera, decreases the player's health.

strange about the disappearing thing... i have yet to experience it.


srfstudio
Registered User
Quote
2018-10-30 21:18:32

That's a good idea, I will try that also, cheers!

Your comment made me experiment further, it seems that the Minotaur is disappearing only if the game is running from CC & it's happening with Chrome, Mozilla & Opera but if I start the game by using the built html file everything is o.k. & nothing is disappearing :)

I can run built html locally only in Firefox but I believe that everything would be normal also in Chrome or Opera. I will try uploading the html to Newgrounds & give it a go with all browsers.

Btw I'm on Win7 & my CC is using localhost:9600 to run WebGL.


Create reply:


Posted by: (you are not logged in)


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