My Boolean In Another Script Won't Change State












0















thank you for reading this. I am quite confused why for some reason this code will not set live round to true when the laser spawns, but it will set the spawn origin to the correct game object and detach it from the parent, anyone got anything? And before you ask, no I don't set live round to false anywhere until I destroy the laser itself.
Thank you for any help you have!



private void Start()
{
if (gameObject.name == "Big Laser(Clone)")
{
spawnOrigin = GetComponentInParent<BigShip>();
spawnOrigin.liveRound = true;
transform.parent = null;
}
}









share|improve this question


















  • 2





    unity is not my domain of knowledge, but I can tell you nobody will be able to guess what happens in other parts of your code. please debug your program (there are watches which will break into the debugger whenever the value of liveRound changes, for example), then provide a minimal, complete example so the problem could be reproduced.

    – dlatikay
    Nov 24 '18 at 21:42











  • @dlatikay Good call debugging it with vs, it never occurred to me to do that when using unity. I'll try that and come back with more info

    – Hagwill
    Nov 25 '18 at 9:01











  • Thank you so much, god do I feel stupid for not using vs debugging. You have saved me a lot of frustration and time my friend all the best to you @dlatikay!

    – Hagwill
    Nov 25 '18 at 10:10


















0















thank you for reading this. I am quite confused why for some reason this code will not set live round to true when the laser spawns, but it will set the spawn origin to the correct game object and detach it from the parent, anyone got anything? And before you ask, no I don't set live round to false anywhere until I destroy the laser itself.
Thank you for any help you have!



private void Start()
{
if (gameObject.name == "Big Laser(Clone)")
{
spawnOrigin = GetComponentInParent<BigShip>();
spawnOrigin.liveRound = true;
transform.parent = null;
}
}









share|improve this question


















  • 2





    unity is not my domain of knowledge, but I can tell you nobody will be able to guess what happens in other parts of your code. please debug your program (there are watches which will break into the debugger whenever the value of liveRound changes, for example), then provide a minimal, complete example so the problem could be reproduced.

    – dlatikay
    Nov 24 '18 at 21:42











  • @dlatikay Good call debugging it with vs, it never occurred to me to do that when using unity. I'll try that and come back with more info

    – Hagwill
    Nov 25 '18 at 9:01











  • Thank you so much, god do I feel stupid for not using vs debugging. You have saved me a lot of frustration and time my friend all the best to you @dlatikay!

    – Hagwill
    Nov 25 '18 at 10:10
















0












0








0








thank you for reading this. I am quite confused why for some reason this code will not set live round to true when the laser spawns, but it will set the spawn origin to the correct game object and detach it from the parent, anyone got anything? And before you ask, no I don't set live round to false anywhere until I destroy the laser itself.
Thank you for any help you have!



private void Start()
{
if (gameObject.name == "Big Laser(Clone)")
{
spawnOrigin = GetComponentInParent<BigShip>();
spawnOrigin.liveRound = true;
transform.parent = null;
}
}









share|improve this question














thank you for reading this. I am quite confused why for some reason this code will not set live round to true when the laser spawns, but it will set the spawn origin to the correct game object and detach it from the parent, anyone got anything? And before you ask, no I don't set live round to false anywhere until I destroy the laser itself.
Thank you for any help you have!



private void Start()
{
if (gameObject.name == "Big Laser(Clone)")
{
spawnOrigin = GetComponentInParent<BigShip>();
spawnOrigin.liveRound = true;
transform.parent = null;
}
}






c# unity3d boolean






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 24 '18 at 20:45









HagwillHagwill

227




227








  • 2





    unity is not my domain of knowledge, but I can tell you nobody will be able to guess what happens in other parts of your code. please debug your program (there are watches which will break into the debugger whenever the value of liveRound changes, for example), then provide a minimal, complete example so the problem could be reproduced.

    – dlatikay
    Nov 24 '18 at 21:42











  • @dlatikay Good call debugging it with vs, it never occurred to me to do that when using unity. I'll try that and come back with more info

    – Hagwill
    Nov 25 '18 at 9:01











  • Thank you so much, god do I feel stupid for not using vs debugging. You have saved me a lot of frustration and time my friend all the best to you @dlatikay!

    – Hagwill
    Nov 25 '18 at 10:10
















  • 2





    unity is not my domain of knowledge, but I can tell you nobody will be able to guess what happens in other parts of your code. please debug your program (there are watches which will break into the debugger whenever the value of liveRound changes, for example), then provide a minimal, complete example so the problem could be reproduced.

    – dlatikay
    Nov 24 '18 at 21:42











  • @dlatikay Good call debugging it with vs, it never occurred to me to do that when using unity. I'll try that and come back with more info

    – Hagwill
    Nov 25 '18 at 9:01











  • Thank you so much, god do I feel stupid for not using vs debugging. You have saved me a lot of frustration and time my friend all the best to you @dlatikay!

    – Hagwill
    Nov 25 '18 at 10:10










2




2





unity is not my domain of knowledge, but I can tell you nobody will be able to guess what happens in other parts of your code. please debug your program (there are watches which will break into the debugger whenever the value of liveRound changes, for example), then provide a minimal, complete example so the problem could be reproduced.

– dlatikay
Nov 24 '18 at 21:42





unity is not my domain of knowledge, but I can tell you nobody will be able to guess what happens in other parts of your code. please debug your program (there are watches which will break into the debugger whenever the value of liveRound changes, for example), then provide a minimal, complete example so the problem could be reproduced.

– dlatikay
Nov 24 '18 at 21:42













@dlatikay Good call debugging it with vs, it never occurred to me to do that when using unity. I'll try that and come back with more info

– Hagwill
Nov 25 '18 at 9:01





@dlatikay Good call debugging it with vs, it never occurred to me to do that when using unity. I'll try that and come back with more info

– Hagwill
Nov 25 '18 at 9:01













Thank you so much, god do I feel stupid for not using vs debugging. You have saved me a lot of frustration and time my friend all the best to you @dlatikay!

– Hagwill
Nov 25 '18 at 10:10







Thank you so much, god do I feel stupid for not using vs debugging. You have saved me a lot of frustration and time my friend all the best to you @dlatikay!

– Hagwill
Nov 25 '18 at 10:10














1 Answer
1






active

oldest

votes


















0














If you sure didn't change your variable in code, I think this problem here is you get component spawnOrigin not correct. Just check spawnOrigin is correct component you want to get by Debug.Log or set break point in visual studio.






share|improve this answer
























  • I did check it via the print function and even made the spawn origin public as to be able to click it in the editor and see what it is cached to and everything seems correct... Thanks for the help though!

    – Hagwill
    Nov 25 '18 at 9:00











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53462213%2fmy-boolean-in-another-script-wont-change-state%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









0














If you sure didn't change your variable in code, I think this problem here is you get component spawnOrigin not correct. Just check spawnOrigin is correct component you want to get by Debug.Log or set break point in visual studio.






share|improve this answer
























  • I did check it via the print function and even made the spawn origin public as to be able to click it in the editor and see what it is cached to and everything seems correct... Thanks for the help though!

    – Hagwill
    Nov 25 '18 at 9:00
















0














If you sure didn't change your variable in code, I think this problem here is you get component spawnOrigin not correct. Just check spawnOrigin is correct component you want to get by Debug.Log or set break point in visual studio.






share|improve this answer
























  • I did check it via the print function and even made the spawn origin public as to be able to click it in the editor and see what it is cached to and everything seems correct... Thanks for the help though!

    – Hagwill
    Nov 25 '18 at 9:00














0












0








0







If you sure didn't change your variable in code, I think this problem here is you get component spawnOrigin not correct. Just check spawnOrigin is correct component you want to get by Debug.Log or set break point in visual studio.






share|improve this answer













If you sure didn't change your variable in code, I think this problem here is you get component spawnOrigin not correct. Just check spawnOrigin is correct component you want to get by Debug.Log or set break point in visual studio.







share|improve this answer












share|improve this answer



share|improve this answer










answered Nov 25 '18 at 3:16









Trung BuiTrung Bui

913




913













  • I did check it via the print function and even made the spawn origin public as to be able to click it in the editor and see what it is cached to and everything seems correct... Thanks for the help though!

    – Hagwill
    Nov 25 '18 at 9:00



















  • I did check it via the print function and even made the spawn origin public as to be able to click it in the editor and see what it is cached to and everything seems correct... Thanks for the help though!

    – Hagwill
    Nov 25 '18 at 9:00

















I did check it via the print function and even made the spawn origin public as to be able to click it in the editor and see what it is cached to and everything seems correct... Thanks for the help though!

– Hagwill
Nov 25 '18 at 9:00





I did check it via the print function and even made the spawn origin public as to be able to click it in the editor and see what it is cached to and everything seems correct... Thanks for the help though!

– Hagwill
Nov 25 '18 at 9:00


















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53462213%2fmy-boolean-in-another-script-wont-change-state%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

A CLEAN and SIMPLE way to add appendices to Table of Contents and bookmarks

Calculate evaluation metrics using cross_val_predict sklearn

Insert data from modal to MySQL (multiple modal on website)