Andy90 Posted September 26, 2023 Share Posted September 26, 2023 Hello i want to ask if there is a forward calculation for a vec3 ? Quote Link to comment Share on other sites More sharing options...
Josh Posted September 26, 2023 Share Posted September 26, 2023 It looks like the Unity "forward" constant is just Vec3(0,0,1). What exactly are you trying to do? Maybe entity.move(0,0,1) is what you are looking for? Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
MarKli Posted September 26, 2023 Share Posted September 26, 2023 If you are controlling a physics object then I think what you are looking for is Josh. But I think they're looking for this. https://gamedev.stackexchange.com/questions/190054/how-to-calculate-the-forward-up-right-vectors-using-the-rotation-angles I use this in the Ultra Engine for a free camera without collision. Quote Link to comment Share on other sites More sharing options...
Andy90 Posted September 26, 2023 Author Share Posted September 26, 2023 2 hours ago, Josh said: It looks like the Unity "forward" constant is just Vec3(0,0,1). What exactly are you trying to do? Maybe entity.move(0,0,1) is what you are looking for? Yes the move was what I was looking for. A function to get a vector before the entity would be good, so you could for example spawn something before the character like whats @MarKlilinked Quote Link to comment Share on other sites More sharing options...
Josh Posted September 26, 2023 Share Posted September 26, 2023 You can use Transform:Normal(0,0,1,entity,nil): https://www.leadwerks.com/learn?page=API-Reference_Object_Math_Transform_Normal Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
reepblue Posted September 26, 2023 Share Posted September 26, 2023 I recall suggesting things like Vec3().Forward()/Up() after I was trying to apply a concept done in Unity to Leadwerks. Quote Cyclone - Ultra Game System - Component Preprocessor - Tex2TGA - Darkness Awaits Template (Leadwerks) If you like my work, consider supporting me on Patreon! Link to comment Share on other sites More sharing options...
Andy90 Posted October 12, 2023 Author Share Posted October 12, 2023 I collaborated with ChatGPT to create a 'lookat' function. While it's not a direct 'forward' function, I believe it can be helpful to others. function LookAt(position, pitch, yaw, distance) pitch = math.rad(pitch) yaw = math.rad(yaw) local forward = Vec3() forward.x = math.cos(pitch) * math.sin(yaw) forward.y = -math.sin(pitch) forward.z = math.cos(pitch) * math.cos(yaw) local forward_length = math.sqrt(forward.x ^ 2 + forward.y ^ 2 + forward.z ^ 2) forward.x = forward.x / forward_length forward.y = forward.y / forward_length forward.z = forward.z / forward_length forward.x = forward.x * distance + position.x forward.y = forward.y * distance + position.y forward.z = forward.z * distance + position.z return forward end 2 Quote Link to comment Share on other sites More sharing options...
Alienhead Posted October 12, 2023 Share Posted October 12, 2023 Handy function there, .. but don't forget LE has an optimized Point built in. https://www.leadwerks.com/learn?page=API-Reference_Object_Entity_Point Quote I'm only happy when I'm coding, I'm only coding when I'm happy. Link to comment Share on other sites More sharing options...
Andy90 Posted October 12, 2023 Author Share Posted October 12, 2023 Yeah i know. Maybe "lookAt" is the wrong name for the function. Is more the Vec3 at the point where the entity (camera) is looking at 1 Quote Link to comment Share on other sites More sharing options...
Alienhead Posted October 12, 2023 Share Posted October 12, 2023 Gotcha, point a Vec3() position with math instead of an entity.. cool. Quote I'm only happy when I'm coding, I'm only coding when I'm happy. Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.