Smart types

Blitz3D Forums/Blitz3D Beginners Area/Smart types

Ben(t)(Posted 2007) [#1]
I have recently found how to use types but now I am trying to get my ai file to update the type units but blitz3d says that the types can't do that
what am I doing wrong?


Who was John Galt?(Posted 2007) [#2]
Post some example code otherwise nobody will understand your question.


Ben(t)(Posted 2007) [#3]
okay

type beast
field entity
end type

(here's where it goes arwy)

for s.beast=each beast
if entitydistance(s/entity,player)< 45 then
pointentity s/entity,player
animateentity s/entity (I don't remember)
moveentity s/entity,0,0,.7
endif
next

this hasn't worked so far what's going on?


H&K(Posted 2007) [#4]
you have no beasts?

1) Post some code that does something
2) Say what it doesnt do
3) Say what is supposed to do

The error (for example), may be that each baests Forward isnt the same as the model, so pointentity is making the back point to the player. But without more information than "here's where it goes arwy" who can tell?


Ben(t)(Posted 2007) [#5]
here is my code

Graphics3D 600,400,32,2
SeedRnd(MilliSecs())
units=1
floors=2


Type beast
Field entity
End Type


player=CreatePivot()
camera=CreateCamera(player)
PositionEntity camera,0,3,0
EntityType player,units

Global beast=CreateCube()
PositionEntity beast,0,5,0
EntityColor beast,255,0,0
EntityType beast,units
HideEntity beast

ground=CreatePlane()
PositionEntity ground,0,-3,0
EntityType ground,floors

Collisions units,units,2,3
Collisions units,floors,2,3

While Not KeyHit(1)


If KeyHit(2) Then
s.beast=New beast
s\entity=CopyEntity(beast)
PositionEntity beast,Rnd(-20,20),5,Rnd(-20,20)
EndIf

For s.beast=Each beast
If EntityDistance(s\entity,player)<45 Then
PointEntity s\entity,player
MoveEntity s\entity,0,0,.3
EndIf
Next



this is what is wrong
For s.beast=Each beast
gravity(s/entity,1)
Next

it says arithmetic operatior cannot be applied to custom type objects

gravity(player,1)


;keymovement
If KeyDown(17) Then MoveEntity player,0,0,.5
If KeyDown(31) Then MoveEntity player,0,0,-.5
If KeyDown(30) Then MoveEntity player,-.5,0,0
If KeyDown(32) Then MoveEntity player,.5,0,0

;Mouse movement
Local x_speed#,y_speed#
x_speed=(MouseXSpeed()-x_speed)/2+x_speed
y_speed=(MouseYSpeed()-y_speed)/2+y_speed
MoveMouse 320,240
TurnEntity player,0,-x_speed,0
TurnEntity camera,-y_speed,0,0
UpdateWorld
RenderWorld
Flip
Wend
End

Function gravity(unit$,speed#)
TranslateEntity Unit$,0,-speed#,0
End Function


b32(Posted 2007) [#6]
It's a typo, the slash should be a backslash:
;this is what is wrong
For s.beast=Each beast
gravity(s\entity,1) ;;;  <------- here
Next



Ben(t)(Posted 2007) [#7]
thank you so much!

also the cube I have replaced with a spider.b3d
when I do this

For s.beast=Each beast
If EntityDistance(s\entity,player)<45 Then
PointEntity s\entity,player
MoveEntity s\entity,0,0,.3

; it says that there is no animation
animate s\entity
; but I thought that it was and exact copy of the animated.b3d

EndIf
Next


Yahfree(Posted 2007) [#8]
maybe your using "Loadmesh" and not "LoadAnimMesh"??


Ben(t)(Posted 2007) [#9]
once again thank you now my ai works perfectly I'll post a demo in a week or two


Ben(t)(Posted 2007) [#10]
here's a random question but what did the programers use to create blitz3d?


b32(Posted 2007) [#11]
I believe it was C++:
http://www.blitzbasic.com/Community/posts.php?topic=42657


Ben(t)(Posted 2007) [#12]
that's what I thought because I tried running it on an older computer and the computer said the visual c++ wasn't right


b32(Posted 2007) [#13]
You mean, you ran blitz3d on an older computer, and you got a c++ error ? That's interesting ?


Ben(t)(Posted 2007) [#14]
well they were ohh 1998, what was weird was blitz wouldn't run but maplet ran hella fast I had good textures loaded, no lag what so ever


Ben(t)(Posted 2007) [#15]
speaking of maplet how would I go about finding code that creates shadows like that?


b32(Posted 2007) [#16]
It is called a lightmapper. I think you can find a code example for that in the code archives on this site.


Ben(t)(Posted 2007) [#17]
oh okay thanks