Forum Discussion
Infinite
13 years agoHonored Guest
Human scans in Unity. Unity dev help needed.
Hi all,
I'm trying to find the right place to ask if anyone can help me with Unity. I'm trying to publish some nude human scan assets so people can view them with Unity on the Rift. Similar to these:
https://vimeo.com/64769947
I have very little Unity experience. So far I can get my assets in no problem with the Rift OVRPlayerController and build a .exe but I'm trying to find out how to add a free roaming flying camera (script?), that works with the Rift rendering and OVRPlayerController.
I'm trying to match the smoothness of the controls in UDK. Whereby you can activate 'fly' and 'slowmo 0.3' to control camera flight and speed. I would publish with UDK but it doesn't seem as universal or as user friendly as a Unity pack.
Any help would be greatly appreciated and perhaps rewarded with some cool nude scan demos!
I'm trying to find the right place to ask if anyone can help me with Unity. I'm trying to publish some nude human scan assets so people can view them with Unity on the Rift. Similar to these:
https://vimeo.com/64769947
I have very little Unity experience. So far I can get my assets in no problem with the Rift OVRPlayerController and build a .exe but I'm trying to find out how to add a free roaming flying camera (script?), that works with the Rift rendering and OVRPlayerController.
I'm trying to match the smoothness of the controls in UDK. Whereby you can activate 'fly' and 'slowmo 0.3' to control camera flight and speed. I would publish with UDK but it doesn't seem as universal or as user friendly as a Unity pack.
Any help would be greatly appreciated and perhaps rewarded with some cool nude scan demos!
42 Replies
Replies have been turned off for this discussion
- antigravityExplorer
"Infinite" wrote:
I have very little Unity experience. So far I can get my assets in no problem and build a .exe but I'm trying to find out how to add a free roaming camera (script?), that works with the Rift rendering and OVRPlayerController.
Any help would be greatly appreciated and perhaps rewarded with some cool nude scan demos!
The OVRPlayerController is the Free Roaming Camera- just set a bounding box on your ground plane and you should be able to nav with the keyboard or joystick.. unless by free roaming you mean with the ability to fly? - InfiniteHonored Guest
"antigravity" wrote:
"Infinite" wrote:
I have very little Unity experience. So far I can get my assets in no problem and build a .exe but I'm trying to find out how to add a free roaming camera (script?), that works with the Rift rendering and OVRPlayerController.
Any help would be greatly appreciated and perhaps rewarded with some cool nude scan demos!
The OVRPlayerController is the Free Roaming Camera- just set a bounding box on your ground plane and you should be able to nav with the keyboard or joystick.. unless by free roaming you mean with the ability to fly?
Thanks for the reply."Infinite" wrote:
I'm trying to match the smoothness of the controls in UDK. Whereby you can activate 'fly' and 'slowmo 0.3' to control camera flight and speed. I would publish with UDK but it doesn't seem as universal or as user friendly as a Unity pack.
Yes, I mean the ability to fly freely. - craigotronHonored GuestI found this snippet courtesy of cyberreality, which might help:
"cybereality" wrote:
In OVRPlayerController.cs in the function UpdateMovement(), you can add the following:if (Input.GetKey(KeyCode.F)) Jump();
This will let you press the F key to jump. You may also want to edit the properties in Unity to get a better feel to the jump. In the OVRPlayerController script properties there is the Motor->Jump Force. And Physics->Gravity Modifier.
Hope that helps.
Seems like you might be able to fly by tweaking the Gravity Modifier.
Great scans, BTW. I'm just getting up to speed with my Asus Xtion and Skanect. Yours are much higher quality. Very impressive. - antigravityExplorer
"Infinite" wrote:
Yes, I mean the ability to fly freely.
aah.. a real quick fix might be binding two keys to the up/down motion of a giant invisible ground plane with physics applied.
Still new to unity myself so theres probably a more elegant solution out there. - dbuckHonored Guestgot a ton of variations of that, let me package one up for you ;)
*time passes*
using UnityEngine;
using System.Collections;
public class FlyCamera : MonoBehaviour {
public float Speed = 1;
public bool DontRequireMouseclick = false;
private Vector3 _moveDirection;
void Update () {
if (Input.GetMouseButton(0) || DontRequireMouseclick)
{
_moveDirection = new Vector3(Input.GetAxis("Horizontal"), Input.GetAxis("FloatUPDOWN"), Input.GetAxis("Vertical"));
if (_moveDirection != Vector3.zero)
{
_moveDirection = transform.TransformDirection(_moveDirection);
_moveDirection *= Speed * Time.deltaTime;
transform.position += _moveDirection;
}
}
if (Input.GetKey(KeyCode.RightBracket))
{
Speed = Speed + (Time.deltaTime*15);
}
if (Input.GetKey(KeyCode.LeftBracket))
{
Speed = Speed - (Time.deltaTime*15);
}
}
}
This should work for you, save as FlyCamera.cs somewhere in the project
Drag in the Assets/OVR/Prefabs/OVRCameraController prefab into the hierarchy window
then add this script to the root of the prefab in the scene
delete the old 'maincamera' since it's no longer needed
then in the menu, we need to add an axis to use for up/down, so:
go to Edit -> Project Settings -> Input
click the little arrow to expand the list
select the first 'Vertical' item in the list
hit Control-D (or Command-D if in OSX) to duplicate the item
in the now duplicated version, go in and change the Name to FloatUPDOWN and the Negative/Positive buttons to C/E respectively..
It's pretty no-frills, but it'll get you started. mostly taken from the unify wiki somewhere if I remember correctly.
Unfortunately I left the rift at work this weekend, or I'd make sure it worked for real ;) if not, i'll dig it up next week if you're still stuck.
Cheers. - InfiniteHonored Guest
"craigotron" wrote:
I found this snippet courtesy of cyberreality, which might help:"cybereality" wrote:
In OVRPlayerController.cs in the function UpdateMovement(), you can add the following:if (Input.GetKey(KeyCode.F)) Jump();
This will let you press the F key to jump. You may also want to edit the properties in Unity to get a better feel to the jump. In the OVRPlayerController script properties there is the Motor->Jump Force. And Physics->Gravity Modifier.
Hope that helps.
Seems like you might be able to fly by tweaking the Gravity Modifier.
Great scans, BTW. I'm just getting up to speed with my Asus Xtion and Skanect. Yours are much higher quality. Very impressive.
Thanks! I will try that out.
There are lots of cool scanning solutions on the market, I hope some day a really high resolution democratized version will be out to capture 4D. Someday it will be trivial to scan high resolution motion, that will be allot of fun! especially in VR."antigravity" wrote:
"Infinite" wrote:
Yes, I mean the ability to fly freely.
aah.. a real quick fix might be binding two keys to the up/down motion of a giant invisible ground plane with physics applied.
Still new to unity myself so theres probably a more elegant solution out there.
This could be an option. I'm still very new to Unity though."dbuck" wrote:
got a ton of variations of that, let me package one up for you ;)
*time passes*
using UnityEngine;
using System.Collections;
public class FlyCamera : MonoBehaviour {
public float Speed = 1;
public bool DontRequireMouseclick = false;
private Vector3 _moveDirection;
void Update () {
if (Input.GetMouseButton(0) || DontRequireMouseclick)
{
_moveDirection = new Vector3(Input.GetAxis("Horizontal"), Input.GetAxis("FloatUPDOWN"), Input.GetAxis("Vertical"));
if (_moveDirection != Vector3.zero)
{
_moveDirection = transform.TransformDirection(_moveDirection);
_moveDirection *= Speed * Time.deltaTime;
transform.position += _moveDirection;
}
}
if (Input.GetKey(KeyCode.RightBracket))
{
Speed = Speed + (Time.deltaTime*15);
}
if (Input.GetKey(KeyCode.LeftBracket))
{
Speed = Speed - (Time.deltaTime*15);
}
}
}
This should work for you, save as FlyCamera.cs somewhere in the project
Drag in the Assets/OVR/Prefabs/OVRCameraController prefab into the hierarchy window
then add this script to the root of the prefab in the scene
delete the old 'maincamera' since it's no longer needed
then in the menu, we need to add an axis to use for up/down, so:
go to Edit -> Project Settings -> Input
click the little arrow to expand the list
select the first 'Vertical' item in the list
hit Control-D (or Command-D if in OSX) to duplicate the item
in the now duplicated version, go in and change the Name to FloatUPDOWN and the Negative/Positive buttons to C/E respectively..
It's pretty no-frills, but it'll get you started. mostly taken from the unify wiki somewhere if I remember correctly.
Unfortunately I left the rift at work this weekend, or I'd make sure it worked for real ;) if not, i'll dig it up next week if you're still stuck.
Cheers.
Many thanks for this. This sounds good, a little more comprehensive. I followed all your steps but I couldn't get it too work, even after save and project build. The e key did as usual and rotated the camera on the horizontal axis, c did nothing :?

- SDMExplorerFor flying around in Unity, I just edited the OVRPlayerController.cs script. R key is up, F key is down, pretty simple.
Not a Unity expert, nor coding expert, I'm sure others will post better code, but this works exactly as I'd like it to (lets you fly freely but also "stick" on the ground/stairs or such when you "land").
Any way, not sure if this is exactly what you are looking for, but to replicate:
Open the OVRPlayerController.cs script up in Monodevelop or such, and near the start of the actual code (line 48) you'll see:
public float GravityModifier = 0.379f;
change to:
public float GravityModifier = 0.0f;
In the // Update section, line 145, change the MoveThrottle.y line to be the same as the MoveThrottle.x and MoveThrottle.z lines. So it becomes:
MoveThrottle.y /= motorDamp;
Bit below that is the // Gravity section, change last line in that section (line 148 I think) to:
moveDirection.y += 0;
Go down to // Update Movement...//Consolidate all movement code here bit next, bit below that you'll see (line 195):
bool moveForward = false; followed by several others. Just below the existing bool entities, add two new ones:
bool moveUp = false;
bool moveDown = false;
Same format as those above the added lines.
Just a bit below that is the //WASD section. Just add these two lines after the existing WASD entries:
if (Input.GetKey(KeyCode.R)) moveUp = true;
if (Input.GetKey(KeyCode.F)) moveDown = true;
Once again formatted the same as the previous lines of code in that section. Next section is // No positional movement if we are in the air. Just add slashes before the two following code lines there so they become:
//if (!Controller.isGrounded)
// MoveScale = 0.0f;
Last bit is to go // Run! section, which is just a few more lines down, and add these lines at the bottom of that section:
if (moveUp)
MoveThrottle += DirXform.TransformDirection(Vector3.up * moveInfluence) * BackAndSideDampen;
if (moveDown)
MoveThrottle += DirXform.TransformDirection(Vector3.down * moveInfluence) * BackAndSideDampen;
Once again formatted the same as the lines of code immediately preceding.
Hope that you can follow the above, that it works as you'd like. I'd just post the script for you, but not sure if that'd be against the rules or not.
Love your work by the way, beautiful model, tastefully done. - InfiniteHonored Guest
"SDM" wrote:
Hope that you can follow the above, that it works as you'd like. I'd just post the script for you, but not sure if that'd be against the rules or not.
Love your work by the way, beautiful model, tastefully done.
Hi SDM, really big thank you for taking the time to write that! I really appreciate it. :D
I got that to work perfectly. Very good first results for movement. It's one way to move.
Do you think there is a way to allow movement to just flow in the direction your facing. This is how UDK works. You can rotate the POV freely and just move forwards, eliminating the need to move up or down by just using your facing direction to fly. Although you can still use E (up) Space (down) to translate up or down as well.
If I could get that working it would be ideal for flying through space viewing multiple scans at any angle and pace.
Thanks for the complement on the scans, I've got lots to show off. - moujaExplorerSo glad to read about your work in Unity. I often have a look at your vimeo videos for checking about an eventual release. your scans are gorgeous. In some way it reminds me the extroardinary scenes when the time is stopped in the Cashback movie. Probably my ultimate fantasy. :)
sample of this movie (NSFW) :
https://www.youtube.com/watch?v=ECWmbY5_tUE - InfiniteHonored Guest
"mouja" wrote:
So glad to read about your work in Unity. I often have a look at your vimeo videos for checking about an eventual release. your scans are gorgeous. In some way it reminds me the extroardinary scenes when the time is stopped in the Cashback movie. Probably my ultimate fantasy. :)
sample of this movie (NSFW) :
https://www.youtube.com/watch?v=ECWmbY5_tUE
Ha, looks like a cool movie I will have to check it out.
I've been blown a way with Unity today. Incredible program, so many features and lots of online help. I've been testing with custom shaders and scripts for various things.
Thanks to SDM I can navigate around in fly mode and using R and F to move up or down, although great it's not that intuitive. It would be amazing to be able to fly in the direction the camera is facing.
Does anyone have any ideas for this? combined with OVRPlayerController?
Quick Links
- Horizon Developer Support
- Quest User Forums
- Troubleshooting Forum for problems with a game or app
- Quest Support for problems with your device
Other Meta Support
Related Content
- 5 months ago
- 16 days ago