Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
  • Help Room /
avatar image
0
Question by gosolo2 · Jun 25, 2017 at 12:58 AM · camerascript.character controlleroculus riftrotatetowards

[ SOLVED ]Parent which holds character controller rotates towards camera ( child ) is pointing

Hi guys. This script bellow works fine but to make it works it adds a speed to the character ( I want the character moves only when I press a button. If the speed is zero the script wouldn't works.

I already have a script which will make the character moves mapped to button( axis ) on the xbox controller. All that I need is another script ( or to have the script bellow corrected ).

I am doing a game for Oculus Rift and I realised it will be better if my character moves towards where the camera is pointing only when I press the button ( dealing with axis here ).

This script works fine but it will add a speed to the character ( I don't want that. I would like to move the character only when I press a button). If the speed is zero the parent where the character controller is placed wouldn't rotates where the camera is facing.

I really appreciate any help you can provide.


using System.Collections; using UnityEngine;

public class cameraRiftmoves : MonoBehaviour { public float speed = 0; // moves 10 units every second

 // Use this for initialization
 private void Start()
 {
 }

 // Update is called once per frame
 private void Update()
 {

     transform.Translate(Camera.main.transform.forward * Time.deltaTime * speed, Space.World);
 }

}


Comment
Add comment · Show 1
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image gosolo2 · Jun 25, 2017 at 05:48 AM 0
Share

I think the problem is with " Camera.main.transform.forward " . I just want the Parent where the Character Controller is to take the Camera direction not sending the Character forward. This script will work only when the Character goes forward. " I tried " transform.rotation = Camera.main.transform.rotation; " but it didn't works but
the Character keeping rotating and I think this occur because it has to be in world space... how I can fix that.

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by gosolo2 · Jun 26, 2017 at 12:55 PM

alt text

NEVER MINDI. I GOT IT


the-one.png (104.1 kB)
Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image gosolo2 · Jun 26, 2017 at 01:18 PM 0
Share

All that you need is just one FS$$anonymous$$ placed on the capsule with 3 actions. One Variable ( Vector3 ) in this case called $$anonymous$$OVE$$anonymous$$ENT. That is all.

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

146 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

camera script problems and can't see the selected object 0 Answers

Character controller for fixed perspective camera (moving relative to arbitrary point on screen) 0 Answers

How do I get Oculus Touch Controllers to move my character controller? 0 Answers

How can i move my camera forward independent of its pitch? 1 Answer

Show device camera preview (Android & iOS) 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges