Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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 /
avatar image
0
Question by Bentoon · Oct 20, 2014 at 06:04 AM · cameraitweenpath

Camera switching with iTween Touch

Hello I am using iTween to control the Camera on a path with Touch (or arrow Keys)

This script (below) works well and gives me a visual editor (yay) But now I want to SWITCH to a New path and still control it with touch

it's a PITA

So I guess the easiest thing is on an event (like a mouse Up) where I want to switch to a new path

is just switch to a New Camera with the same Camera follow Path script on it

Maybe? But it's not working and I am perplexed

Here is My Main Camera follow Path Script:

 using UnityEngine;
 using System.Collections;
 
 public class FlythroughCameraController1 : MonoBehaviour {
     public Transform[] movePath;
     public Transform[] lookPath;
     public Transform lookTarget;
     public float percentage;
     //public Transform[] path;
     public float speed = 0.1f;
 
 
     private float redPosition = .16f;
     private float bluePosition = .53f;
     private float greenPosition = 1;
 //    private float purplePosition = 1.2;
 
     
     void Start(){
     }
 
     void Update () {
         if (Input.touchCount > 0) {
             
             Touch touch = Input.GetTouch(0);
             
             if (touch.phase == TouchPhase.Moved) {
                 percentage += touch.deltaPosition.x * speed / Screen.height;
                 percentage = Mathf.Clamp01(percentage);
                 // ROBERTBU                iTween.PutOnPath(gameObject,path,percentage);
                 iTween.PutOnPath(gameObject,movePath,percentage);
                 iTween.PutOnPath(lookTarget,lookPath,percentage);
                 transform.LookAt(iTween.PointOnPath(lookPath,percentage));
                 //transform.LookAt(iTween.PointOnPath(path,percentage+.05f));
             }
         }
 
 
         if(Input.GetKey(KeyCode.UpArrow))
         {
             percentage += speed * Time.deltaTime;
         }
         if(Input.GetKey(KeyCode.DownArrow))
         {
             percentage -= speed * Time.deltaTime;
         }
         percentage = Mathf.Clamp01(percentage);
         iTween.PutOnPath(gameObject,movePath,percentage);
         iTween.PutOnPath(lookTarget,lookPath,percentage);
         transform.LookAt(iTween.PointOnPath(lookPath,percentage));
     }
 

     void OnDrawGizmos(){
         iTween.DrawPath(movePath,Color.magenta);
         iTween.DrawPath(lookPath,Color.cyan);
         Gizmos.color=Color.black;
         Gizmos.DrawLine(transform.position,lookTarget.position);
     }
     
     void SlideTo(float position){
         iTween.Stop(gameObject);
         iTween.ValueTo(gameObject,iTween.Hash("from",percentage,"to",position,"time",2,"easetype",iTween.EaseType.easeInOutCubic,"onupdate","SlidePercentage"));    
     }
     
     void SlidePercentage(float p){
         percentage=p;
     }
 }
 

A mouse Up event happens to switch Cameras, but doesn't seem to work


 using UnityEngine;
 using System.Collections;
 
 public class MouseUp : MonoBehaviour {
 
     
     public Camera oldCamera;
     public Camera newCamera;
     
 
     void OnMouseUp()
     {
         oldCamera.camera.active = false;
         newCamera.camera.active = true;
         }
 
 }
 


Any help is greatly appreciated

Thanks

~be

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 yashpal · Oct 20, 2014 at 09:00 AM 0
Share

I am not fully understand question but this might be problem. void On$$anonymous$$ouseUp() is only called when game object is having collider is on the gameObject it attached to it. and user click(touch) on the that game object.

1 Reply

· Add your reply
  • Sort: 
avatar image
0
Best Answer

Answer by mr-gelmir · Oct 20, 2014 at 08:52 AM

I'm making a wild guess here, but could it have something to do with you getting the camera property from your Camera variable?

you could try this:

      public Camera oldCamera;
      public Camera newCamera;         
  
      void OnMouseUp()
      {
          oldCamera.enabled = false;
          newCamera.enabled = true;
      }

now, I'm not sure, but it might be worth trying?

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 Bentoon · Oct 20, 2014 at 04:28 PM 0
Share

$$anonymous$$r Gelmir

I'm not sure if that's exactly it - but when I switched the old Camera & New Camera in the inspector it worked

Thank you !

Perhaps I might just trigger new scene though - that might be the best idea

Thanks

~be

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

29 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

Related Questions

Alternatives to iTweenPath for creating path for camera 2 Answers

Switching Between (many) different iTween Paths (C#) 0 Answers

iTween even velocity 9 Answers

Scale an iTweenPath 0 Answers

Lerping between Camera Paths 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