Ambiera ForumDiscussions, Help and Support. |
|
|
|||||
|
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); |
||||
|
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. |
||||
|
Or you may try using physics engine for that, not sure if this works. |
||||
|
i got it from a buddy of mine and i asked him if he used a chat thing and he said yes |
||||
|
so it wont work i guess. its been so long cense i did anything it copper cube and in games in general |
||||
|
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. |
||||
|
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. |
||||
|
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. |
||||
|
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 |
|