Ambiera Forum

Discussions, Help and Support.

Ambiera Forum > CopperCube > Programming and Scripting
behavior script header

neo96732
Registered User
Quote
2023-02-11 21:52:24

hello its been so long since i tried to make a script
can anyone exsplain the header for me i been trying out a script but it will not load this is the script




// Ricochet script

var bounceCount = 0;

function ricochet(bullet, collidedNode) {

var surfaceNormal = bullet.getAttribute("collisionNormal");

var reflect = vec3.reflect(bullet.getAttribute("velocity"), surfaceNormal);


bullet.setAttribute("velocity", reflect);

bounceCount++;

if (bounceCount >= 5) {

bullet.remove();
}
}

// Attach the ricochet function to the bullet node
bullet.setAttribute("onCollision", ricochet);


okeoke
Registered User
Quote
2023-02-12 15:39:56

Hi neo96732
Could you please tell if you generated this script with chat gpt?:) It doesn't really like it's using the real coppercube api.
It would be so cool if you could just get a normal vector like you do in your script:)
Basically, it's not a header issue, i guess. If you want to implement ricochet functionality, you will have to do a lot of vector magic calculations yourself. I would probably not implement this feature at all if it's not a key gameplay element of your game.


okeoke
Registered User
Quote
2023-02-12 16:08:46

Or you may try using physics engine for that, not sure if this works.


neo96732
Registered User
Quote
2023-02-14 02:48:14

i got it from a buddy of mine and i asked him if he used a chat thing and he said yes


neo96732
Registered User
Quote
2023-02-14 02:50:02

so it wont work i guess. its been so long cense i did anything it copper cube and in games in general


okeoke
Registered User
Quote
2023-02-14 08:58:14

Yep, I don't think it will work. I also tried ChatGPT for that purpose with pretty much the same result:) It's actually pretty good for html and css though.

I think, the better approach would be to describe what you're trying to achieve in more details (i.e. desktop game/webgl game, 2d/3d, instant should or duplicate object), and ask the forum. Probably, someone can point you to the right solution.


Guest
Guest
Quote
2023-02-15 21:54:37

The code looks like it's using the CopperLicht API.

https://www.ambiera.com/copperli...

Maybe check there if you are making a web game.


okeoke
Registered User
Quote
2023-02-16 08:34:54

Unfortunately, it doesn't look like copperlicht either.

The only function from this which I somehow familiar to me is Vector3d.reflect, which is definitely taken from Unity. It even has the the same parameters - direction and surface normal. There are no reflect function to the vector3d class in licht.

There is also no getAttribute/setAttribute methods for scene node class in copperlicht. There is no node.remove method, which removes the node, you can only remove children nodes, so you do node.getParent().removeChild(node) in order to do that.

Overall, once again it's just a bunch of characters generated by AI.


serge
Registered User
Quote
2023-02-16 12:46:35

The proper way to use a script in the tutorial doc of coppercube. It's in JavaScript reference If it's related to coppercube 6.6


Create reply:


Posted by: (you are not logged in)


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