質問編集履歴

3

コード追加

2021/04/14 02:11

投稿

退会済みユーザー
test CHANGED
File without changes
test CHANGED
@@ -704,4 +704,68 @@
704
704
 
705
705
 
706
706
 
707
+ ```
708
+
709
+ using System.Collections;
710
+
711
+ using System.Collections.Generic;
712
+
713
+ using UnityEngine;
714
+
715
+
716
+
717
+ public class Circle : MonoBehaviour
718
+
719
+ {
720
+
721
+ // Start is called before the first frame update
722
+
723
+ void Start()
724
+
725
+ {
726
+
727
+
728
+
729
+ }
730
+
731
+
732
+
733
+ // Update is called once per frame
734
+
735
+ void Update()
736
+
737
+ {
738
+
739
+
740
+
741
+ }
742
+
743
+
744
+
745
+ private void OnCollisionEnter2D(Collision2D collision)
746
+
747
+ {
748
+
749
+ if (collision.gameObject.tag == "Square")
750
+
751
+ {
752
+
753
+ Debug.Log("サークルとスクウェアが接触しました");
754
+
755
+ Debug.Log( collision);
756
+
757
+ Debug.Log( gameObject);
758
+
759
+ }
760
+
761
+ }
762
+
763
+ }
764
+
765
+ コード
766
+
767
+ ```
768
+
769
+
770
+
707
771
  ![イメージ説明](601a12bfa2c71ae0955929ccc3e6b13b.png)

2

InvokeがUpdate内で動作するコード

2021/04/14 02:11

投稿

退会済みユーザー
test CHANGED
File without changes
test CHANGED
@@ -523,3 +523,185 @@
523
523
 
524
524
 
525
525
  ![イメージ説明](65da977c2948635fd461f5888bdc765f.png)
526
+
527
+
528
+
529
+
530
+
531
+ ```
532
+
533
+
534
+
535
+
536
+
537
+ void Start()
538
+
539
+ {
540
+
541
+
542
+
543
+ }
544
+
545
+
546
+
547
+
548
+
549
+
550
+
551
+ void Update()
552
+
553
+ {
554
+
555
+
556
+
557
+
558
+
559
+
560
+
561
+ if (Input.GetKey(KeyCode.Space))
562
+
563
+ {
564
+
565
+ samp.Move();
566
+
567
+ // Debug.Log(samp);
568
+
569
+
570
+
571
+
572
+
573
+
574
+
575
+ Invoke("Vanish2", 1.5f);
576
+
577
+ }
578
+
579
+ }
580
+
581
+
582
+
583
+ private void Vanish2()
584
+
585
+ {
586
+
587
+ samp.Vanish();
588
+
589
+ }
590
+
591
+ }
592
+
593
+
594
+
595
+ コード
596
+
597
+ ```
598
+
599
+ ```
600
+
601
+ using System.Collections;
602
+
603
+ using System.Collections.Generic;
604
+
605
+ using UnityEngine;
606
+
607
+
608
+
609
+ public class Sample : MonoBehaviour
610
+
611
+ {
612
+
613
+ public float xspeed;
614
+
615
+ public float yspeed;
616
+
617
+
618
+
619
+
620
+
621
+ public GameObject squ;
622
+
623
+ public GameObject cir;
624
+
625
+ public GameObject cup;
626
+
627
+
628
+
629
+ Rigidbody2D rigidcir;
630
+
631
+ Rigidbody2D rigidcup;
632
+
633
+ Rigidbody2D rigidsqu;
634
+
635
+
636
+
637
+
638
+
639
+
640
+
641
+ private void Start()
642
+
643
+ {
644
+
645
+ rigidcir = cir.GetComponent<Rigidbody2D>();
646
+
647
+ rigidsqu = squ.GetComponent<Rigidbody2D>();
648
+
649
+ rigidcup = cup.GetComponent<Rigidbody2D>();
650
+
651
+ }
652
+
653
+
654
+
655
+
656
+
657
+ private void Update()
658
+
659
+ {
660
+
661
+
662
+
663
+ }
664
+
665
+
666
+
667
+
668
+
669
+ public void Move()//これを呼び出したい
670
+
671
+ {
672
+
673
+ cir.transform.Translate(-xspeed, -yspeed, 0);
674
+
675
+ squ.transform.Translate(-xspeed, yspeed, 0);
676
+
677
+
678
+
679
+
680
+
681
+ // Debug.Log(squ);
682
+
683
+ }
684
+
685
+ public void Vanish()
686
+
687
+ {
688
+
689
+ cup.SetActive(false);
690
+
691
+ }
692
+
693
+
694
+
695
+
696
+
697
+ }
698
+
699
+
700
+
701
+ コード
702
+
703
+ ```
704
+
705
+
706
+
707
+ ![イメージ説明](601a12bfa2c71ae0955929ccc3e6b13b.png)

1

Switch発動のオブジェクトに乗ってしまう図を追加

2021/04/14 02:07

投稿

退会済みユーザー
test CHANGED
File without changes
test CHANGED
@@ -519,3 +519,7 @@
519
519
  コード
520
520
 
521
521
  ```
522
+
523
+
524
+
525
+ ![イメージ説明](65da977c2948635fd461f5888bdc765f.png)