Pardon the terrible username! It’ll be fixed, given whenever Unity support gets around to it. Initially when I was lurking I didn’t care too much what the username was and they accepted this. Bwaha.
I love Python and therefore most relate to Boo, so I’ve been using that, but the documentation is sub-par. This is also my first experience with Unity in general, so I hope you’ll bear with me. I’m trying to get collision to work, so as a test I’m trying to get an upper boundary to work, however it does not seem to do what I want. The boundary is already in the appropriate spot, however the blocks go right through each other! I’ve tried every combination of triggers set to on & off, OnTriggerEnter and OnCollisionEnter used. I wonder where I could be going wrong?
This has always been a stumbling block for me when I’m building a game so I’d at least like to get it working. This is my best shot! Please teach this poor newbie.
This is the player script:
import UnityEngine
class player_movement (MonoBehaviour):
def Start ():
pass
##How the hell do I make this public??
##This does not work:
#public reachedtop = false
def Update ():
/* These next variables can only be declared as Vector2 variables if they identify
as a ‘float’ apparently… however I have only found these 3 float-like types:
single, double and decimal. None seemed to work. */
#vecspeedup = 0 # as decimal = 0.0
#vecspeeddown = 0 # as decimal = 0.0
#vecspeedleft = 0 # as decimal = 0.0
#vecspeedright = 0 # as decimal = 0.0
speed0 = 0 # as decimal = 0.0
speed1 = 0 # as decimal = 0.0
reachedtop = false
def OnTriggerEnter(c as Collision):
if c.gameObject.CompareTag("top"):
reachedtop = true
##deltaTime keeps it in the same relative time of a locked framerate
##Look up how to specifically obtain 60fps
speed0 = (0.0 * Time.deltaTime)
speed1 = (400.0 * Time.deltaTime)
##Ship movement, GetKey, GetKeyDown, GetKeyUp...
##Also, use KeyCode.whatever to access input directly
if Input.GetKey(KeyCode.UpArrow):
if reachedtop == true:
vecspeedup = Vector2(0,0) * speed0
else:
vecspeedup = Vector2(0,1) * speed1
transform.Translate(vecspeedup)
elif Input.GetKey(KeyCode.DownArrow):
##other buttons...
##END
Error output:
Boo Compiler version 0.9.5.5 (2.0 (Visual Studio built mono))
-----CompilerOutput:-stderr----------
WARNING: booc is not using the Boo.Lang.Compiler.dll next to booc.exe. Using ‘C:\Program Files\Unity\Editor\Data\Mono\lib\mono\unity\Boo.Lang.Compiler.dll’ instead of ‘C:\Program Files\Unity\Editor\Data\Mono\lib\mono\unity\Boo.Lang.Compiler.dll’. You may need to remove boo dlls from the GAC using gacutil or Mscorcfg.
Assets/Project/Scripts/player_movement.boo(21,9): BCW0003: WARNING: Unused local variable ‘OnTriggerEnter’.
1 warning(s).
How do I get public to work in Boo?
How do I get those collisions to activate my code?
The warning seems to be saying that OnTriggerEnter is an unused variable. That must not be right. How would that be corrected? Is it particularly different between onTrigger and onCollision?
…Is the compiler producing an error that suggests I manually fix it?
I greatly appreciate all valuable answers!