Getting object reference error when Camera.main.ScreenToWorldPoint is used [duplicate]
This question already has an answer here:
Camera.main is null when performing raycast
2 answers
I am getting error
NullReferenceException: Object reference not set to an instance of an
object SinglePoint.Update () (at Assets/Script/SinglePoint.cs:52)
and this is my block of code
if (Input.GetMouseButtonDown (0)) {
//line 52 where error exists: Vector3
currentPosition=Camera.main.ScreenToWorldPoint(Input.mousePosition);
currentPosition.z=-5.0f;
InstatiateCirclePoint(currentPosition,currentLineRenderer.transform);
}
unity3d
marked as duplicate by Programmer
StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;
$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');
$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Nov 21 '18 at 18:15
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
add a comment |
This question already has an answer here:
Camera.main is null when performing raycast
2 answers
I am getting error
NullReferenceException: Object reference not set to an instance of an
object SinglePoint.Update () (at Assets/Script/SinglePoint.cs:52)
and this is my block of code
if (Input.GetMouseButtonDown (0)) {
//line 52 where error exists: Vector3
currentPosition=Camera.main.ScreenToWorldPoint(Input.mousePosition);
currentPosition.z=-5.0f;
InstatiateCirclePoint(currentPosition,currentLineRenderer.transform);
}
unity3d
marked as duplicate by Programmer
StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;
$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');
$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Nov 21 '18 at 18:15
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
add a comment |
This question already has an answer here:
Camera.main is null when performing raycast
2 answers
I am getting error
NullReferenceException: Object reference not set to an instance of an
object SinglePoint.Update () (at Assets/Script/SinglePoint.cs:52)
and this is my block of code
if (Input.GetMouseButtonDown (0)) {
//line 52 where error exists: Vector3
currentPosition=Camera.main.ScreenToWorldPoint(Input.mousePosition);
currentPosition.z=-5.0f;
InstatiateCirclePoint(currentPosition,currentLineRenderer.transform);
}
unity3d
This question already has an answer here:
Camera.main is null when performing raycast
2 answers
I am getting error
NullReferenceException: Object reference not set to an instance of an
object SinglePoint.Update () (at Assets/Script/SinglePoint.cs:52)
and this is my block of code
if (Input.GetMouseButtonDown (0)) {
//line 52 where error exists: Vector3
currentPosition=Camera.main.ScreenToWorldPoint(Input.mousePosition);
currentPosition.z=-5.0f;
InstatiateCirclePoint(currentPosition,currentLineRenderer.transform);
}
This question already has an answer here:
Camera.main is null when performing raycast
2 answers
unity3d
unity3d
edited Nov 21 '18 at 18:11
Programmer
76.7k1088156
76.7k1088156
asked Nov 21 '18 at 17:02
janicejanice
215
215
marked as duplicate by Programmer
StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;
$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');
$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Nov 21 '18 at 18:15
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
marked as duplicate by Programmer
StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;
$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');
$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Nov 21 '18 at 18:15
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
If this is indeed the correct line of code, you should confirm that you have a Camera added to your scene and that it has the Tag "MainCamera" attached to it.
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
If this is indeed the correct line of code, you should confirm that you have a Camera added to your scene and that it has the Tag "MainCamera" attached to it.
add a comment |
If this is indeed the correct line of code, you should confirm that you have a Camera added to your scene and that it has the Tag "MainCamera" attached to it.
add a comment |
If this is indeed the correct line of code, you should confirm that you have a Camera added to your scene and that it has the Tag "MainCamera" attached to it.
If this is indeed the correct line of code, you should confirm that you have a Camera added to your scene and that it has the Tag "MainCamera" attached to it.
answered Nov 21 '18 at 17:12
Shawn LehnerShawn Lehner
1,260712
1,260712
add a comment |
add a comment |