Help with your scripting

Get Object to Match Camera Movement

Get Object to Match Camera Movement

Postby Shando » 08 Oct 2017, 13:37

Hi All,

I've finally managed to implement my bounds checking for the camera ( including Yaw restrictions :) ).

Now, all I need to be able to do is get the Plane to match the Camera's movements (including rotation!).

I think it would be something along these lines:
Object Position = Camera Position
Object Rotation = Camera Rotation
Object Translate ( i.e. move away from Camera )
Object LookAt Camera


I can easily get the Camera's Position.

There doesn't appear to be a function to get the Camera's Rotation (though I do have this in my bounds checking code, so that's not too much of a problem)

The problem I have is working out the Translation away from the Camera. I assume it's something to do with the Forward Vector and just moving along that? e.g. if the Forward Vector of the Camera is 0.5, 0, -0.5 then I can just multiply this by an amount to get the required Translation step?

Any help would be greatly appreciated.

Shando

edit: actually, thinking about it, I probably don't need the Rotation step, as that would be handled by the LookAt step anyway??
Alienware 17 (i7-4700MQ 2.4GHz 16GB GTX770M Win 10 64)

Love, Hope, Strength http://www.lovehopestrength.co.uk
User avatar
Shando
Skyline Moderator
Skyline Moderator
 
Posts: 476
Joined: 06 Mar 2013, 22:35
Location: Kings Beach, Queensland
Skill: Programmer
Skill: Scripter
Skill: Level Designer

Re: Get Object to Match Camera Movement

Postby SolarPortal » 08 Oct 2017, 14:09

couldnt you just attach the plane to the camera if you need the plane to face the camera all the time.. use the "Entity- Attach" action on the camera and use the tag name of the plane, rotate it and job done :)

The problem I have is working out the Translation away from the Camera. I assume it's something to do with the Forward Vector and just moving along that? e.g. if the Forward Vector of the Camera is 0.5, 0, -0.5 then I can just multiply this by an amount to get the required Translation step?

Yeah, to get a forward vector its quite simple...

First get the direction... normalise the result so it is always in the -1 to -1 range.
Then multiply that direction value by a number e.g. 10 for 10 units away on that direction..
Conceive, Quantify & Do!
Skyline Game Engine - Lead Developer.
Please provide as much information as possible when asking for help.


Specs: OS: Win 10 64bit, CPU: Intel i7 3770 3.4ghz x 4 core(8 threads), GPU: Nvidia GTX 1060 6GB, Ram: 16gig DDR3, Windows on 250gb Samsung Evo 860
User avatar
SolarPortal
Skyline Founder
Skyline Founder
 
Posts: 3071
Joined: 29 Jul 2012, 15:56
Location: UK
Skill: 3D Modeller
Skill: 2D Artist
Skill: Programmer
Skill: Level Designer

Re: Get Object to Match Camera Movement

Postby SpiderMack » 09 Oct 2017, 13:12

On a side node , if object parenting was available, you would only need to drag and drop the plane as sub object of camera in the scene list hierarchy.
(most missing feature :lol: )
User avatar
SpiderMack
Skyline Expert
 
Posts: 437
Joined: 02 Dec 2016, 09:15
Skill: Concept artist
Skill: 3D Modeller
Skill: Level Designer
Skill: Scripter

Re: Get Object to Match Camera Movement

Postby TattieBoJangle » 09 Oct 2017, 13:28

On a side node , if object parenting was available, you would only need to drag and drop the plane as sub object of camera in the scene list hierarchy.
(most missing feature )


In no way would this solve the problem :lol:
Case: CM Storm Trooper CPU: I7 5930k X99 Cooler: Noctua NH-D15 Graphics: Asus GTX 1080 Motherboard: Rampage Extreme V x99 Ram: RipJaws DDR4 3000mhz Storage: x2 SSD Crucial 500GB + x5 2TB Hdd PSU: Evga 1500w OS: Windows 10
User avatar
TattieBoJangle
Skyline Lead Moderator
Skyline Lead Moderator
 
Posts: 842
Joined: 26 Jan 2015, 00:15
Location: United Kingdom
Skill: 3D Modeller
Skill: 2D Artist
Skill: Level Designer
Skill: Great creative


Return to Lua Scripting

Who is online

Users browsing this forum: No registered users and 1 guest

cron