Intermediate Unity 3D for iOS: Part 3/3
16 posts
• Page 1 of 2 • 1, 2
Intermediate Unity 3D for iOS: Part 3/3
This is the official thread to discuss the following blog post: Intermediate Unity 3D for iOS: Part 3/3
- - - - - - - - - - - - - - - - - - - - - - - - - - - -
Ray Wenderlich
Blog: http://www.raywenderlich.com
Twitter: http://twitter.com/rwenderlich
- - - - - - - - - - - - - - - - - - - - - - - - - - - -
Ray Wenderlich
Blog: http://www.raywenderlich.com
Twitter: http://twitter.com/rwenderlich
- - - - - - - - - - - - - - - - - - - - - - - - - - - -
-

rwenderlich - Site Admin
- Posts: 1780
- Joined: Thu Dec 23, 2010 4:14 pm
- Has thanked: 26 times
- Been thanked: 189 times
Re: Intermediate Unity 3D for iOS: Part 3/3
Hi:
I want to thank you for the great tutorial you made. It's incredible that you offered this work for free for hobbysts like me.
The question is that I've been importing the final project into Unity 4 and, unfortunately, the syntax included in the scripts is not compatible. The compiler shows many errors/warnings that I can't solve by myself.
Would it be possible to post an already Unity 4 converted version?
Thank you so much again for your big effort.
Keep up the good work guys.
I want to thank you for the great tutorial you made. It's incredible that you offered this work for free for hobbysts like me.
The question is that I've been importing the final project into Unity 4 and, unfortunately, the syntax included in the scripts is not compatible. The compiler shows many errors/warnings that I can't solve by myself.
Would it be possible to post an already Unity 4 converted version?
Thank you so much again for your big effort.
Keep up the good work guys.
- avispafuu
- n00b
- Posts: 2
- Joined: Tue Aug 28, 2012 10:11 am
- Has thanked: 0 time
- Been thanked: 0 time
Re: Intermediate Unity 3D for iOS: Part 3/3
Hi,
Glad you liked the tutorial.
Any chance you can elaborate on exactly what the error is you're getting (copy & paste the error/log) - and we'll try to figure out what may be the issue.
Cheers,
Josh
Glad you liked the tutorial.
Any chance you can elaborate on exactly what the error is you're getting (copy & paste the error/log) - and we'll try to figure out what may be the issue.
Cheers,
Josh
- josh_newnham
- iOS Tutorial Team Member
- Posts: 6
- Joined: Sun Jan 20, 2013 8:04 pm
- Has thanked: 0 time
- Been thanked: 1 time
Re: Intermediate Unity 3D for iOS: Part 3/3
The error I get is on line 69 of GameMenuController.cs it's a 'parser error' unexpected symbol ' } '. The last } in the script.
- poolenc
- n00b
- Posts: 1
- Joined: Thu Sep 20, 2012 3:22 am
- Has thanked: 0 time
- Been thanked: 0 time
Re: Intermediate Unity 3D for iOS: Part 3/3
Hi - thanks for getting back.
I suspect that's the issue then.
In the code snippets for the GameMenuController's OnGUI method; the final line has a '}' which is associated with the '{' of the OnGUI method. Can you look over your code and ensure that the OnGUI method has the correct opening and closing blocks.
If you're still running into issues - upload the file here and I'll have a look at it.
Josh
I suspect that's the issue then.
In the code snippets for the GameMenuController's OnGUI method; the final line has a '}' which is associated with the '{' of the OnGUI method. Can you look over your code and ensure that the OnGUI method has the correct opening and closing blocks.
If you're still running into issues - upload the file here and I'll have a look at it.
Josh
- josh_newnham
- iOS Tutorial Team Member
- Posts: 6
- Joined: Sun Jan 20, 2013 8:04 pm
- Has thanked: 0 time
- Been thanked: 1 time
Re: Intermediate Unity 3D for iOS: Part 3/3
Hello again and thanks for your reply.
Once this syntax error is removed, other warnings and errors appear in other clases. I've attached a picture of the log window showing the list of problems found after the correction of the extra '}'. I'm not sure if errors could keep on coming up as the manual conversion process takes place, due to the changes made in the Unity 4 architecture. Anyway, thanks again for your help and support.
Greetings.
Once this syntax error is removed, other warnings and errors appear in other clases. I've attached a picture of the log window showing the list of problems found after the correction of the extra '}'. I'm not sure if errors could keep on coming up as the manual conversion process takes place, due to the changes made in the Unity 4 architecture. Anyway, thanks again for your help and support.
Greetings.
- Attachments
-
- Other errors that appear during the Unity 3 to Unity 4 conversion
- unity4_other_errors.png (79.03 KiB) Viewed 1045 times
- avispafuu
- n00b
- Posts: 2
- Joined: Tue Aug 28, 2012 10:11 am
- Has thanked: 0 time
- Been thanked: 0 time
Re: Intermediate Unity 3D for iOS: Part 3/3
Hi,
There is nothing fancy going on so I would be surprised if using Unity 4 (in this instance) would be causing any issue. At a guess I'm thinking it has something to do with the encoding i.e. how are you copying the code out?
Just to be sure; can you confirm you have the methods it's complaining about in your GameMenuController.cs file;
The methods are described in the 'Showing and hiding' section of the tutorial.
... we're slowly getting there
There is nothing fancy going on so I would be surprised if using Unity 4 (in this instance) would be causing any issue. At a guess I'm thinking it has something to do with the encoding i.e. how are you copying the code out?
Just to be sure; can you confirm you have the methods it's complaining about in your GameMenuController.cs file;
- Code: Select all
public void Show(){
// ignore if you are already enabled
if( this.enabled ){
return;
}
_globalTintAlpha = 0.0f;
_leaderboardController.FetchScores();
this.enabled = true;
}
public void Hide(){
this.enabled = false;
}
The methods are described in the 'Showing and hiding' section of the tutorial.
... we're slowly getting there
- josh_newnham
- iOS Tutorial Team Member
- Posts: 6
- Joined: Sun Jan 20, 2013 8:04 pm
- Has thanked: 0 time
- Been thanked: 1 time
Re: Intermediate Unity 3D for iOS: Part 3/3
Hi,
First, thank you so much for this tutorial
you did a really great job
.
Now, i have encountered a little error while copying your code from the Main menu section, it did tell me that it didn't know any List object, i found the using line i needed to add for it to compile (thx google
) : using System.Collections.Generic;
Now, i have a question, i'm trying to change the throwball vector using the point where the user clicked so i can make an elipse with the ball if i want, or a straight shoot, or...
But i encoutered a calculation problem, when i take the touch/click position, it's expressed in screen coordinate (iphone 480x320) and not in the scene space coordinate which i guess would me something like (4x2).
To be a bit more clear, i'll use the ball position, let's say the ball is exactly at the center of the screen from the Main camera pov, and at the center of the scene too.
the scene position of the ball is : (1;1;0) Vector3
but the screen position of the ball is : (240;160) Vector2
so how can i perform the calculation of a vector that uses the scene positions so that the ball doesn't run way too far away??
(i could give you the code i added if you'd like
)
Again, thx a lot for that tutorial, i've been wanting to do some stuff with unity3D for a long time now
First, thank you so much for this tutorial
Now, i have encountered a little error while copying your code from the Main menu section, it did tell me that it didn't know any List object, i found the using line i needed to add for it to compile (thx google
Now, i have a question, i'm trying to change the throwball vector using the point where the user clicked so i can make an elipse with the ball if i want, or a straight shoot, or...
But i encoutered a calculation problem, when i take the touch/click position, it's expressed in screen coordinate (iphone 480x320) and not in the scene space coordinate which i guess would me something like (4x2).
To be a bit more clear, i'll use the ball position, let's say the ball is exactly at the center of the screen from the Main camera pov, and at the center of the scene too.
the scene position of the ball is : (1;1;0) Vector3
but the screen position of the ball is : (240;160) Vector2
so how can i perform the calculation of a vector that uses the scene positions so that the ball doesn't run way too far away??
(i could give you the code i added if you'd like
Again, thx a lot for that tutorial, i've been wanting to do some stuff with unity3D for a long time now
- Saliom
- Baby Hacker
- Posts: 7
- Joined: Thu Jan 10, 2013 11:43 am
- Has thanked: 1 time
- Been thanked: 0 time
Re: Intermediate Unity 3D for iOS: Part 3/3
Hi,
Not exactly 100% sure what you're trying to do but think I understand your question.
In 3D you have 3 spaces, Screen, viewport, and World - what you're trying to do is translate the screen space (points) into 3D. Luckily Unity provides helper methods to make this easier for you; have a read of the following link which explains the Camera.ScreenToWorldSpace method.
http://docs.unity3d.com/Documentation/S ... Point.html
An alternative is to cast a ray out onto a collider and use the hit point. Once again; Unity provides you with the necessary method to convert screen points to a world ray cast;
http://docs.unity3d.com/Documentation/S ... ToRay.html
Josh
Not exactly 100% sure what you're trying to do but think I understand your question.
In 3D you have 3 spaces, Screen, viewport, and World - what you're trying to do is translate the screen space (points) into 3D. Luckily Unity provides helper methods to make this easier for you; have a read of the following link which explains the Camera.ScreenToWorldSpace method.
http://docs.unity3d.com/Documentation/S ... Point.html
An alternative is to cast a ray out onto a collider and use the hit point. Once again; Unity provides you with the necessary method to convert screen points to a world ray cast;
http://docs.unity3d.com/Documentation/S ... ToRay.html
Josh
- josh_newnham
- iOS Tutorial Team Member
- Posts: 6
- Joined: Sun Jan 20, 2013 8:04 pm
- Has thanked: 0 time
- Been thanked: 1 time
Re: Intermediate Unity 3D for iOS: Part 3/3
it should be working with the ScreenToWorldPoint i think 
So i'll try to explain a bit better what i'm trying to do.
I'd like that when the user touch the screend, the ball goes in the direction of that touch.
so in the attachment the touch is the red dot, and the green line is what the ball would do, but if i did push a bit upper of the red dot, the ball would have gone a bit higher, if i pushed lower of the red dot, the ball would have gone lower, ...
is it more clear?
here is what i have :
in the Player script
in the GameController for the FirstTouchVector function :
i'm currently only trying it on the computer, and not on an ios device.
It's almost right, but i have to calculate throwDirection from the ball, which isn't done yet, and i don't really see how i could do it...
So i'll try to explain a bit better what i'm trying to do.
I'd like that when the user touch the screend, the ball goes in the direction of that touch.
so in the attachment the touch is the red dot, and the green line is what the ball would do, but if i did push a bit upper of the red dot, the ball would have gone a bit higher, if i pushed lower of the red dot, the ball would have gone lower, ...
is it more clear?
here is what i have :
in the Player script
- Code: Select all
if( _state == PlayerStateEnum.BouncingBall ){
if( _holdingBall ){
if( GameController.SharedInstance.State == GameController.GameStateEnum.Play && GameController.SharedInstance.TouchDownCount >= 1 ){
Vector2 touchPosition = GameController.SharedInstance.FirstTouchVector;
Camera camera = Camera.mainCamera;
throwDirection = camera.ScreenToWorldPoint(new Vector3(touchPosition.x,touchPosition.y,0.0f));
Debug.Log(throwDirection);
State = PlayerStateEnum.PreparingToThrow;
return;
}
}
in the GameController for the FirstTouchVector function :
- Code: Select all
public Vector2 FirstTouchVector
{
get{
if( IsMobile ){
Debug.Log("position : "+Input.touches[0].position);
return Input.touches[0].position;
} else{
Debug.Log("position : "+Input.mousePosition);
Vector3 mouseVector = Input.mousePosition;
return new Vector2(mouseVector.x,mouseVector.y);
}
}
}
i'm currently only trying it on the computer, and not on an ios device.
It's almost right, but i have to calculate throwDirection from the ball, which isn't done yet, and i don't really see how i could do it...
- Saliom
- Baby Hacker
- Posts: 7
- Joined: Thu Jan 10, 2013 11:43 am
- Has thanked: 1 time
- Been thanked: 0 time
16 posts
• Page 1 of 2 • 1, 2
Who is online
Users browsing this forum: Google [Bot] and 5 guests