ambiera logo

Ambiera Forum

Discussions, Help and Support.

folder icon Ambiera Forum > CopperCube > CopperCube Open discussion
forum topic indicator scripting
person icon
dekon_17
Registered User
Quote
2025-08-11 16:28:01

Wa-a-a-ait a minute... Are you like, dividing 'offset' variable by a vector length?
... offset / Math.sqrt(Math.pow(actualPos.x - posPlayer.x, 2) + Math.pow(actualPos.y - posPlayer.y, 2) + Math.pow(actualPos.z - posPlayer.z, 2))

If so, you can make it a fair bit better, by, first, making a variable for the afforementioned length (because I doubt that you really need to calculate the same thing a bunch of times, waste of performance)
...
//Substract players coordinates from actual pos, then get length of that resulting vector
var length = actualPos.substract(posPlayer).getLength()
..
and, second, just simplify it
...
actualPos.x = posPlayer.x + (actualPos.x - posPlayer.x) * (offset / length);
actualPos.y = posPlayer.y + (actualPos.y - posPlayer.y) * (offset / length);
actualPos.z = posPlayer.z + (actualPos.z - posPlayer.z) * (offset / length);
...


person icon
winter_dev0001
Registered User
Quote
2025-08-11 16:51:07

good idea, i'll try it!

person icon
winter_dev0001
Registered User
Quote
2025-08-11 16:59:10

Yep, works better.
Thanks!

person icon
dekon_17
Registered User
Quote
2025-08-11 21:52:42

Oh, and one more thing. You might've already figured this out, but you can also do the division part with the 'length' variable before the rest. Like
...
var offsetToLength = offset / actualPos.substract(posPlayer).getLength();
...
Didn't think about that initially, but I'll leave this here just in case. After all, I was the one who said:
I doubt that you really need to calculate the same thing a bunch of times, waste of performance


person icon
Monks
Guest
Quote
2025-08-11 21:58:11

Hi winterdev, how does the final product look like now?
Can you show it via youtube?

person icon
winter_dev0001
Registered User
Quote
2025-08-12 20:29:23

I don't see why not (:
https://www.youtube.com/watch?v=...

person icon
Monks
Guest
Quote
2025-08-12 21:55:44

Good job
It seems to be a hlitchy a bit, but i don't know whether the recording software is the issue or not
But, its great, I recommend you use dynamic lighting and lights, and also you use new game assets from online, these will make your gane look more polished

person icon
winter_dev0001
Registered User
Quote
2025-08-12 22:37:07

Don't thank me, the better version is Dekon's.
But i kept my own if the player tries to lift something really heavy and the gun malfunctions, that's where my code executes.


Here's the thing:
I do use dynamic lighting and lights.
But, i am planning to use downloaded game assets.

person icon
Monks
Guest
Quote
2025-08-12 22:54:17

That is absolutely great, i wish you luck, feel free to share your progress with the community,
Are you on Discord?emoji icon_smile

person icon
winter_dev0001
Registered User
Quote
2025-08-12 23:30:52

um.. no, but im that kinda person who would create an account for one person so in a Schrodinger's cat way, i am.

person icon
winter_dev0001
Registered User
Quote
2025-08-12 23:47:42

Okay i logged in my name is 'WinterDev :3'

person icon
Monks
Guest
Quote
2025-08-13 00:21:27

Which server did you join?

person icon
winter_dev0001
Registered User
Quote
2025-08-13 11:07:58

None. i tried to find coppercube game developer servers but i did not find any.. can you recommend me a server?

person icon
winter_dev0001
Registered User
Quote
2025-08-13 11:11:59

Did not find one so i created my own
https://discord.gg/4cwSAqC9

person icon
Monks
Guest
Quote
2025-08-13 11:30:54

Oh okay i've joined, here they are, i recommend joining both

https://discord.gg/kCUtR42m >>This is my server

https://discord.gg/afk3hq7j >>This is the actual discord server dedicated to Coppercube


Create reply:










 

  

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


icon_holyicon_cryicon_devilicon_lookicon_grinicon_kissicon_monkeyicon_hmpf
icon_sadicon_happyicon_smileicon_uhicon_blink   






Copyright© Ambiera e.U. all rights reserved.
Contact | Imprint | Products | Privacy Policy | Terms and Conditions |